------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Output/log.txt
  log type:  text
 opened on:  13 Nov 2024, 09:56:37

. 
. sysdir set PLUS "${dir}/ado"

. mata: mata mlib index
.mlib libraries to be searched are now
    lmatabase;lmataado;lmatabma;lmatacollect;lmataerm;lmatafc;lmatagsem;lmatahetdid;lmataivqreg;lmatajm;lmatalasso;lmatamcmc;lmatameta;lmatami;lmatamixlog;lmatanumlib;lmataopt;lmatapath;lmatapostest;lmatapss;lmatasem;lmatasp;lmatasvy;lmatatab;lasdoc;la
> sgen

. set varabbrev on

. 
. global Do                        "${path}/Do-Files/by_survey"

. global DataPath          "${path}/Data/raw"

. global CleanDataPath "${path}/Data/clean"

. 
. do "${code}/1_Create_harmonized_dataset.do"

. clear all

. cls

. 
. //Step 2: Generate the clean datasets for each IE
.         do "$Do\AGEPR4.do"

. use "$DataPath\AGEP\AGEPR4\AGEP_Round4.dta"

. 
. ***Survey chars***
.         gen year= 2016

.         gen str country="ZAM"

.         gen round=4

.         gen str source= "AGEP_R4"

. 
. ***Age & Urban/Rural*** 
.         rename R4_A103 age

.         drop if age<10 | age>19
(1,454 observations deleted)

.         drop if age==.
(0 observations deleted)

.         
.         destring siteid, replace
siteid: all characters numeric; replaced as int

.         recode siteid (101/105 =1) (106/110 = 0) (211/215=1), gen(urban)
(3,404 differences between siteid and urban)

.         
.         merge 1:1 agepid using "$DataPath\AGEP\AGEPR4\AGEP_Sample.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                         1,831
        from master                         0  (_merge==1)
        from using                      1,831  (_merge==2)

    Matched                             3,404  (_merge==3)
    -----------------------------------------

.         
.         keep if _merge==3
(1,831 observations deleted)

.         tab arms

       arms |      Freq.     Percent        Cum.
------------+-----------------------------------
         SS |        788       23.15       23.15
      SS+HV |        743       21.83       44.98
   SS+HV+SA |        753       22.12       67.10
 ControlInt |        771       22.65       89.75
 ControlExt |        349       10.25      100.00
------------+-----------------------------------
      Total |      3,404      100.00

.         keep if arms==4 | arms==5
(2,284 observations deleted)

. 
. ***Employment***
.         recode R4_A405 (1=1) (2=0) (.n=.), gen(emp)
(987 differences between R4_A405 and emp)

. 
. ***Education***
.         recode R4_A317 (1=1) (2=0), gen(attend)
(53 differences between R4_A317 and attend)

.         gen nvr_enrol=(R4_A301==0)      

.         
. ***Marriage/children***
.         recode R4_A1303 (2/3 = 0) (1= 1) (missing =0), gen(marital_status)
(1,029 differences between R4_A1303 and marital_status)

.         rename R4_A1006 nchild

.         gen child=(nchild!=0)

.         replace child=0 if R4_A1003==2
(640 real changes made)

.         replace child=(nchild==1 | nchild==2 |nchild==3 )
(317 real changes made)

.         label define marital_status 0 "Unmarried" 1 "Married"

.         label values marital_status marital_status

.         
.         rename R4_A1307_1 mar_age

. 
. ***Items***
.         gen mobile=(R4_A407g==1)

. 
. ***Financial Capital***
.         recode R4_A412 (1=1) (2=0), gen(save)
(717 differences between R4_A412 and save)

.         label values save save

.         
.         recode R4_A413 (1=0.5) (2=1) (3=2) (4=3) (5=4) (6=5) (7=8) (8=13) (9=18) (10=23)(11=28)(12=33)(13=38)(14=43)(15=48)(16=75)(17=150)(18=250)(19=350)(20=450)(21=750)(22=1500)(23=2500)(24=3500)(25=4500)(26=5000)(8888=.), gen(save_amount)
(403 differences between R4_A413 and save_amount)

.         replace save_amount=. if save_amount==.n
(717 real changes made, 717 to missing)

.         replace save_amount=save_amount/3.87882661819458
(398 real changes made)

.         recast double save_amount

. 
. ***Aspirations***
.         gen asp_educ=.
(1,120 missing values generated)

.         gen asp_occ=.
(1,120 missing values generated)

.         rename R4_A111 mar_as_age

.         *77 means "Already Married", 88 means "Don't Know", 98 means "Dont want to get married"
.         label define mar_as 77 "Already Married"  88 "Don't Know" 98 "Dont want to get married"

.         label values mar_as_age mar_as

. 
. ***Qualitative Score***
.         *Self-esteem
.                 recode R4_A701 (1=1) (2=0)
(300 changes made to R4_A701)

.                 recode R4_A702 (1=1) (2=0)
(298 changes made to R4_A702)

.                 recode R4_A703 (1=1) (2=0)
(217 changes made to R4_A703)

.                 recode R4_A704 (1=1) (2=0)
(597 changes made to R4_A704)

.                 recode R4_A705 (1=1) (2=0)
(400 changes made to R4_A705)

.                 recode R4_A706 (1=1) (2=0)
(120 changes made to R4_A706)

.                 recode R4_A707 (1=1) (2=0)
(348 changes made to R4_A707)

.                 recode R4_A708 (1=1) (2=0)
(161 changes made to R4_A708)

.                 recode R4_A709 (1=1) (2=0)
(129 changes made to R4_A709)

.                 recode R4_A710 (1=1) (2=0)
(611 changes made to R4_A710)

.         
.                 egen den= rownonmiss(R4_A701 R4_A702 R4_A703 R4_A704 R4_A705 R4_A706 R4_A707 R4_A708 R4_A709 R4_A710)

.                 egen num= rowtotal(R4_A701 R4_A702 R4_A703 R4_A704 R4_A705 R4_A706 R4_A707 R4_A708 R4_A709 R4_A710)

.                 gen se_score= num/den

.                 drop den num

.         
.         *Locus of Control
.                 recode R4_A711 (1=1) (2=0)
(633 changes made to R4_A711)

.                 recode R4_A712 (1=1) (2=0)
(627 changes made to R4_A712)

.                 recode R4_A713 (1=1) (2=0)
(859 changes made to R4_A713)

.                 recode R4_A714 (1=1) (2=0)
(631 changes made to R4_A714)

.                 
.                 egen den= rownonmiss(R4_A711 R4_A712 R4_A713 R4_A714)

.                 egen num= rowtotal(R4_A711 R4_A712 R4_A713 R4_A714)

.                 gen lc_score= num/den

.                 drop den num

.         
.         *Gender attitudes
.                 recode R4_A723 (1=1) (2=0)
(42 changes made to R4_A723)

.                 gen ga_educ=(R4_A723==1)

.                 gen ga_h=.
(1,120 missing values generated)

. // scores closer to 1 mean higher self esteem/locus of control/stronger feminist attitudes 
. 
. **GBV
.         recode R4_A728a (1=1) (2=0) (88 = .), gen(gbv_1)
(733 differences between R4_A728a and gbv_1)

.         recode R4_A728b (1=1) (2=0) (88 = .), gen(gbv_2)
(571 differences between R4_A728b and gbv_2)

.         recode R4_A728c (1=1) (2=0) (88 = .), gen(gbv_3)
(621 differences between R4_A728c and gbv_3)

.         recode R4_A728d (1=1) (2=0) (88 = .), gen(gbv_4)
(820 differences between R4_A728d and gbv_4)

.         recode R4_A728e (1=1) (2=0) (88 = .), gen(gbv_5)
(786 differences between R4_A728e and gbv_5)

.         
.         gen gbv_simple=0 if gbv_1!=. | gbv_2!=. | gbv_3!=. | gbv_4!=. | gbv_5!=.  

.         replace gbv_simple=1 if  gbv_1==1 | gbv_2==1 | gbv_3==1 | gbv_4==1 | gbv_5==1  
(729 real changes made)

.                 
. **SRH 
. 
. foreach i in a b c d e f  g h i {
  2.         
.         gen R4_A904`i'_bis  =  R4_A904`i'
  3.         replace R4_A904`i'_bis = 0 if inlist(R4_A904`i', 2, 3) 
  4. }
(523 real changes made)
(1,000 real changes made)
(518 real changes made)
(882 real changes made)
(692 real changes made)
(880 real changes made)
(1,087 real changes made)
(1,087 real changes made)
(1,081 real changes made)

. 
. local var_list R4_A904a_bis R4_A904b_bis R4_A904c_bis R4_A904d_bis ///
> R4_A904e_bis R4_A904f_bis R4_A904g_bis R4_A904h_bis R4_A904i_bis

. 
. egen know_contraception =rowtotal(`var_list'), missing

. egen know_contracep_miss = rowmiss(`var_list')

. replace know_contraception = 1 if know_contraception >= 1 & know_contraception!=.
(653 real changes made)

. 
. 
. keep year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ se_score lc_score gbv* ga_educ ga_h know_contraception

. 
. compress year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ know_contraception
  variable year was float now int
  variable round was float now byte
  variable urban was int now byte
  variable emp was int now byte
  variable nvr_enrol was float now byte
  variable mar_age was int now byte
  variable marital_status was int now byte
  variable child was float now byte
  variable mobile was float now byte
  variable save was int now byte
  variable asp_educ was float now byte
  variable mar_as_age was int now byte
  variable asp_occ was float now byte
  variable know_contraception was float now byte
  (32,480 bytes saved)

. 
. save "$CleanDataPath\clean_AGEP_Girls_Round4.dta", replace
file C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Data/clean\clean_AGEP_Girls_Round4.dta saved

. 
end of do-file

.         clear all

.         do "$Do\AGIK.do"

. use "$DataPath\AGIK\R1R2R3_NBO_public_Feb2021.dta"

. append using "$DataPath\AGIK\R1R2R3_WAJ_public_Feb2021.dta", force
(note: variable q813f1 was str5 in the using data, but will be byte now)
(note: variable q817a was byte in the using data, but will be str57 now)
(note: variable q829_e5_other was byte in the using data, but will be str121 now)
(note: variable q1551j1 was byte in the using data, but will be str20 now)
(variable h_q101_other was str35, now str84 to accommodate using data's values)
(variable h_q120a was byte, now int to accommodate using data's values)
(variable h_q120f was byte, now int to accommodate using data's values)
(variable h_q402 was str63, now str66 to accommodate using data's values)
(variable h_q410 was str70, now str77 to accommodate using data's values)
(variable q301m6_other was str14, now str159 to accommodate using data's values)
(variable q320ba was int, now long to accommodate using data's values)
(variable q323a_other was str175, now str255 to accommodate using data's values)
(variable q408ee was str76, now str77 to accommodate using data's values)
(variable q408kk was str11, now str21 to accommodate using data's values)
(variable q408mm was str6, now str16 to accommodate using data's values)
(variable q410pa was str49, now str64 to accommodate using data's values)
(variable q413a was int, now long to accommodate using data's values)
(variable q826_days was byte, now int to accommodate using data's values)
(label DK already defined)
(label DK88 already defined)
(label DK8888 already defined)
(label KCPE already defined)
(label KES already defined)
(label KHS already defined)
(label KSH already defined)
(label YN already defined)
(label absent already defined)
(label age_educ already defined)
(label agree already defined)
(label attend already defined)
(label born already defined)
(label budget already defined)
(label chances already defined)
(label civil already defined)
(label class already defined)
(label close already defined)
(label comfort already defined)
(label comp already defined)
(label county already defined)
(label days already defined)
(label decision already defined)
(label faretype already defined)
(label fluency already defined)
(label form already defined)
(label freq already defined)
(label frequenc already defined)
(label frequse already defined)
(label h_q302 already defined)
(label highgrade already defined)
(label import already defined)
(label language already defined)
(label location already defined)
(label locus already defined)
(label marital already defined)
(label mix already defined)
(label myth already defined)
(label often already defined)
(label permit already defined)
(label place already defined)
(label q1005 already defined)
(label q1006 already defined)
(label q101 already defined)
(label q1010 already defined)
(label q1011 already defined)
(label q1012 already defined)
(label q1014 already defined)
(label q1015 already defined)
(label q1018 already defined)
(label q1021 already defined)
(label q1022 already defined)
(label q103 already defined)
(label q105 already defined)
(label q106 already defined)
(label q108 already defined)
(label q108b already defined)
(label q109 already defined)
(label q110 already defined)
(label q1103 already defined)
(label q111 already defined)
(label q112 already defined)
(label q114m5 already defined)
(label q116 already defined)
(label q1212 already defined)
(label q1213 already defined)
(label q1304 already defined)
(label q1305 already defined)
(label q1310 already defined)
(label q1316 already defined)
(label q1319 already defined)
(label q1505 already defined)
(label q1506 already defined)
(label q1511 already defined)
(label q1512 already defined)
(label q1513 already defined)
(label q1518 already defined)
(label q1519 already defined)
(label q1545 already defined)
(label q1553 already defined)
(label q1554 already defined)
(label q1555 already defined)
(label q1556 already defined)
(label q203 already defined)
(label q210 already defined)
(label q212 already defined)
(label q303 already defined)
(label q306 already defined)
(label q310m already defined)
(label q320b already defined)
(label q405 already defined)
(label q408 already defined)
(label q418 already defined)
(label q421 already defined)
(label q424 already defined)
(label q426 already defined)
(label q430 already defined)
(label q432 already defined)
(label q433 already defined)
(label q502 already defined)
(label q503 already defined)
(label q708 already defined)
(label q709 already defined)
(label q710 already defined)
(label q712 already defined)
(label q804 already defined)
(label q809 already defined)
(label q810 already defined)
(label q811 already defined)
(label q811a already defined)
(label q813 already defined)
(label q814 already defined)
(label q815 already defined)
(label q817 already defined)
(label q818 already defined)
(label q819 already defined)
(label q821 already defined)
(label q822 already defined)
(label q823 already defined)
(label q823m47b already defined)
(label q826 already defined)
(label q829 already defined)
(label q829_e already defined)
(label q831 already defined)
(label q832 already defined)
(label q833 already defined)
(label q835 already defined)
(label q901 already defined)
(label q903 already defined)
(label q904 already defined)
(label read already defined)
(label relat2 already defined)
(label relation already defined)
(label religion already defined)
(label reside already defined)
(label risk already defined)
(label scale already defined)
(label sch_cat already defined)
(label sch_lev already defined)
(label sch_type already defined)
(label schexp already defined)
(label site already defined)
(label studyarm already defined)
(label transp already defined)
(label transport already defined)
(label travel already defined)
(label true already defined)
(label truth already defined)
(label when already defined)
(label worry already defined)
(label year already defined)

. save "$CleanDataPath\AGIK_combined.dta", replace
file C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Data/clean\AGIK_combined.dta saved

. use "$CleanDataPath\AGIK_combined.dta"

. 
. ***Survey chars***
.         gen year= 2015

.         gen str country="KEN"

.         recode round (1=0) (2=1) (3=2)
(15,597 changes made to round)

.         keep if round==0
(10,398 observations deleted)

.         gen str source= "AGIK"

. 
. ***Age & Urban/Rural*** 
.         gen urban=0+(site==1|site==3)

.         drop if age<10 | age>19
(54 observations deleted)

.         drop if age==.
(0 observations deleted)

. 
. ***Employment***
.         recode q404 (1=1) (2=0) (.n=.), gen(emp)
(0 differences between q404 and emp)

. 
. ***Education***
.         gen nvr_enrol=(c_q301==0)

.         gen enrol=1-(q310!=.)

.         replace enrol=0 if nvr_enrol==1
(489 real changes made)

.         gen attend=enrol

.         replace attend=0 if c_q309==0
(5 real changes made)

.         replace attend=1 if q310!=. & c_q316!=. | c_q317!=.
(4 real changes made)

. 
. ***Marriage/children***
.         label define marital_status 0 "Unmarried" 1 "Married"

.         rename q801 marital_status

.         label values marital_status marital_status

. 
.         gen child=0

.         replace child=1 if q1003!=.
(5 real changes made)

.         gen nchild=child

.         replace nchild=q1003-q1002b if q1003!=. 
(5 real changes made, 5 to missing)

. 
. ***Items***
.         recode q407h (0=0) (1=1) (.=.), gen(mobile)
(0 differences between q407h and mobile)

. 
. ***Financial Capital***
.         rename q412 save

.         label define save 1 "Yes" 0 "No"

.         label values save save

. 
.         gen double save_amount=q413a/39.0404777526855
(4,363 missing values generated)

. 
. ***Aspirations***
.         rename q804a mar_as_age

.         replace mar_as_age =q804 if q804==88 |q804==98
(2,443 real changes made)

.         replace mar_as_age=77 if marital_status==1
(21 real changes made)

.         label define mar_as 77 "Already Married"  88 "Don't Know" 98 "Dont want to get married"

.         label values mar_as_age mar_as

.         rename q809a mar_age

.         
.         gen asp_educ=4 if q1402c==3 | q1402c==4
(430 missing values generated)

.         replace asp_educ=2 if asp_educ==. & (q1402b==3 | q1402b==4)
(65 real changes made)

.         replace asp_educ=1 if asp_educ==. & (q1402a==3 | q1402a==4)
(15 real changes made)

. 
.         gen asp_occ=.
(5,145 missing values generated)

. 
. ***Qualitative Score***
.         *Self-esteem
.                 replace q602=1-q602
(5,119 real changes made)

.                 replace q602=1-q603
(2,035 real changes made)

.                 egen den= rownonmiss(q601 q602 q603 q604 q605 q606 q607 q608 q609 q610)

.                 egen num=rowtotal(q601 q602 q603 q604 q605 q606 q607 q608 q609 q610)

.                 gen se_score= num/den
(26 missing values generated)

.                 drop num den

.         *Locus of Control
.                 recode q611 (1=1) (2=0)
(2,398 changes made to q611)

.                 recode q612 (1=0) (2=1)
(5,119 changes made to q612)

.                 recode q613 (1=0) (2=1)
(5,119 changes made to q613)

.                 recode q614 (1=0) (2=1)
(5,119 changes made to q614)

.                 egen den=rownonmiss(q611 q612 q613 q614)

.                 egen num =rowtotal(q611 q612 q613 q614)

.                 gen lc_score=num/den
(26 missing values generated)

.                 drop num den

.         *Gender attitudes
.                 recode q618 (1=0) (0=1) (.=.), gen(ga_educ)
(5,119 differences between q618 and ga_educ)

.                 recode q619 (1=0) (0=1)
(5,119 changes made to q619)

.                 recode q620 (1=0) (0=1)
(5,119 changes made to q620)

.                 recode q621 (1=0) (0=1)
(5,119 changes made to q621)

.                 egen den=rownonmiss(q618 q619 q620 q621 q622)

.                 egen num=rowtotal(q618 q619 q620 q621 q622)

.                 gen ga_score= num/den
(26 missing values generated)

.                 drop num den

.                 
.                 recode q618 (1=1) (0=0) (missing=.), gen(ga_new)
(0 differences between q618 and ga_new)

.                 
.                 
. // scores closer to 1 mean higher self esteem/locus of control/more feminist/equal attitudes 
. 
. **Health
.         gen health= q702/10
(26 missing values generated)

.         gen health_year= q701/10 
(26 missing values generated)

. 
. **GBV
.         rename q1302a gbv_1

.         rename q1302b gbv_2

.         rename q1302c gbv_3

.         rename q1302d gbv_4

.         rename q1302e gbv_5

.         
.         gen gbv_simple=0 if gbv_1!=. | gbv_2!=. | gbv_3!=. | gbv_4!=. | gbv_5!=.  
(26 missing values generated)

.         replace gbv_simple=1 if  gbv_1==1 | gbv_2==1 | gbv_3==1 | gbv_4==1 | gbv_5==1  
(2,596 real changes made)

.         
.         rename q1308 gbv_x

. 
. **SRH   
.         recode q904a (1 2 = 1) (3=0)
(0 changes made to q904a)

.         recode q904b (1 2 = 1) (3=0)
(0 changes made to q904b)

.         recode q904c (1 2 = 1) (3=0)
(0 changes made to q904c)

.         recode q904d (1 2 = 1) (3=0)
(0 changes made to q904d)

.         recode q904e (1 2 = 1) (3=0)
(0 changes made to q904e)

.         recode q904f (1 2 = 1) (3=0)
(0 changes made to q904f)

.         recode q904g (1 2 = 1) (3=0)
(0 changes made to q904g)

.         recode q904h (1 2 = 1) (3=0)
(0 changes made to q904h)

.         recode q904i (1 2 = 1) (3=0)
(0 changes made to q904i)

.         
.         gen know_contraception = .
(5,145 missing values generated)

.         replace know_contraception=0 if q904a==0 | q904b==0 | q904c==0 | q904d==0 | q904e==0 | q904f==0 | q904g==0 | q904h==0 | q904i==0 
(0 real changes made)

.         replace know_contraception=1 if  q904a==1 | q904b==1 | q904c==1 | q904d==1 | q904e==1 | q904f==1 | q904g==1 | q904h==1 | q904i==1 
(0 real changes made)

. 
.         
.         
. keep year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ se_score lc_score gbv* ga_* know_contraception 

. 
. compress year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ se_score lc_score gbv*
  variable year was float now int
  variable urban was float now byte
  variable nvr_enrol was float now byte
  variable attend was float now byte
  variable child was float now byte
  variable nchild was float now byte
  variable asp_educ was float now byte
  variable asp_occ was float now byte
  variable gbv_simple was float now byte
  (133,770 bytes saved)

. 
. save "$CleanDataPath\clean_AGIK_combined.dta", replace
file C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Data/clean\clean_AGIK_combined.dta saved

. 
. 
. 
. 
end of do-file

.         clear all

.         do "$Do\Agile.do"

. use "$DataPath\Agile\Adolescent Survey_June 16 2023.dta"

. 
. ***Survey chars***
.         gen year=2023

.         gen country="NGA"

.         gen round=0

.         gen source= "Agile"

. 
. ***Age & Urban/Rural*** 
.         
.         gen urban=(location!="Rural")

.         replace urban=. if location==""
(27 real changes made, 27 to missing)

.         
.         rename ch_15_last_age age

.         drop if age<10 | age>19
(26 observations deleted)

.         drop if age==.
(0 observations deleted)

.         
. ***Employment***
.         
.         gen occ=.
(8,197 missing values generated)

.         replace occ=1 if ac_1_activty_6month_1==1 
(227 real changes made)

.         replace occ=2 if ac_1_activty_6month_2==1 
(151 real changes made)

.         replace occ=3 if ac_1_activty_6month_3==1 |ac_1_activty_6month_4==1 | ac_1_activty_6month_5==1 |ac_1_activty_6month_6==1 |ac_1_activty_6month_7==1 | ac_1_activty_6month_8==1 |ac_1_activty_6month_9==1
(2,658 real changes made)

.         
.         gen emp=(occ!=.)

. 
. ***Education***
.         gen attend=1

.         gen nvr_enrol=0

.         
. ***Marriage/children***
.         gen marital_status=(ch_10_marital_status==2)

.         gen child=.
(8,197 missing values generated)

.         gen nchild=.
(8,197 missing values generated)

.         gen mar_age=.
(8,197 missing values generated)

.         
. ***Items***
.         gen mobile=. 
(8,197 missing values generated)

. 
. ***Financial Capital***
.         gen save=.
(8,197 missing values generated)

.         gen double save_amount=.
(8,197 missing values generated)

. 
. ***Aspirations***
.         recode aa3_4_constraint (1/3=2) (4=3) (5/8=4), gen(asp_educ)
(8,108 differences between aa3_4_constraint and asp_educ)

.         gen mar_as_age= aa3_9_idealmarry
(255 missing values generated)

.         replace mar_as_age=88 if mar_as_age>80
(285 real changes made)

.         replace mar_as_age=77 if marital_status==1
(42 real changes made)

.         
.         recode aa3_2_jobchoice (1/3=3) (4/7=4) (8=1) , gen(asp_occ)
(636 differences between aa3_2_jobchoice and asp_occ)

. 
. ***Qualitative Score***
.         *Self-efficacy
.                 gen score= (se2_1_solve_diff_problms) + (se2_2_some1_oposes) + (se2_3_acomplsh_goals) + (se2_4_deal_unxpectd_evnts) + (se2_5_handle_un4sin_evnts) + (se2_6_solve_requird_efort) + (se2_7_coping_ability) + (se2_8_sevral_solutns_prblm) + 
> (se2_9_think_solutn_prblm) + (se2_10_handle_whtevr)

.                 gen se_ans= (se2_1_solve_diff_problms!=.) + (se2_2_some1_oposes!=.) + (se2_3_acomplsh_goals!=.) + (se2_4_deal_unxpectd_evnts!=.) + (se2_5_handle_un4sin_evnts!=.) + (se2_6_solve_requird_efort!=.) + (se2_7_coping_ability!=.) + (se2_8_se
> vral_solutns_prblm!=.) + (se2_9_think_solutn_prblm!=.) + (se2_10_handle_whtevr!=.)

.                 gen se_score= score/(se_ans*4)

.                 drop score

.         *Locus of Control
.                 gen lc_score=.
(8,197 missing values generated)

.                 
.         *Gender attitudes
.                 gen ga1=(le_1a_atitude_chldmarrge!=0)+(le_1b_atitude_chldmarrge!=0)-1

.                 gen ga3=at_9_fathrs_share_chore/5

.         
.                 rename ga1 ga_educ

.                 rename ga3 ga_h

. 
.                 
. // scores closer to 1 mean higher self esteem/locus of control/stronger feminist attitudes 
. 
. **GBV
.         
.         recode at_11_wife_noconsent (1/3 = 0) (4 5 = 1), gen(gbv_1)
(8,197 differences between at_11_wife_noconsent and gbv_1)

.         recode at_12_wife_neglcts_kids (1/3 = 0) (4 5 = 1), gen(gbv_2)
(8,197 differences between at_12_wife_neglcts_kids and gbv_2)

.         recode at_13_wife_argue (1/3 = 0) (4 5 = 1), gen(gbv_3)
(8,197 differences between at_13_wife_argue and gbv_3)

.         recode at_14_wife_refuse_sex (1/3 = 0) (4 5 = 1), gen(gbv_4)
(8,197 differences between at_14_wife_refuse_sex and gbv_4)

.         recode at_15_wife_burn_food (1/3 = 0) (4 5 = 1), gen(gbv_5)
(8,197 differences between at_15_wife_burn_food and gbv_5)

.         
.         gen gbv_simple=0 if gbv_1!=. | gbv_2!=. | gbv_3!=. | gbv_4!=. | gbv_5!=.  

.         replace gbv_simple=1 if  gbv_1==1 | gbv_2==1 | gbv_3==1 | gbv_4==1 | gbv_5==1  
(5,114 real changes made)

. 
. keep year round source country urban age emp occ nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ se_score lc_score  gbv_simple ga_*

. 
. compress year round source country urban age emp occ nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ 
  variable year was float now int
  variable round was float now byte
  variable urban was float now byte
  variable age was int now byte
  variable emp was float now byte
  variable occ was float now byte
  variable nvr_enrol was float now byte
  variable attend was float now byte
  variable mar_age was float now byte
  variable marital_status was float now byte
  variable child was float now byte
  variable nchild was float now byte
  variable mobile was float now byte
  variable save was float now byte
  variable mar_as_age was float now byte
  variable save_amount was double now byte
  (401,653 bytes saved)

. 
.         label define marital_status 0 "Unmarried" 1 "Married"

.         label values marital_status marital_status 

.         label define mar_as 77 "Already Married"  88 "Don't Know" 98 "Dont want to get married"

.         label values mar_age mar_as_age mar_as

.         label define occ  0 "None" 1 "Home" 2 "Agriculture" 3 "Modest Status" 4 "High Status" 5 "Other"

.         label values occ asp_occ occ

.         
. save "$CleanDataPath\clean-agile.dta", replace
file C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Data/clean\clean-agile.dta saved

. 
. 
end of do-file

.         clear all

.         do "$Do\Benin CCT.do"

. use "$DataPath\SWEDD Benin\CCT\ADO_Volet_2_clean.dta"

. 
. ***Survey chars***
.         gen year= 2022

.         gen round =0

.         gen str source= "SWEDD_Benin_CCT"

.         gen country = "BEN"

. 
. ***Age & Urban/Rural***
.         rename lm6_ADO age

.         drop if age<10 | age>19
(195 observations deleted)

.         drop if age==.
(0 observations deleted)

. 
.         decode id4, generate(id_4)

.         gen place=id_4+","+id5

.         tab place

                 place |      Freq.     Percent        Cum.
-----------------------+-----------------------------------
     ALIBORI,BANIKOARA |        251        4.15        4.15
      ALIBORI,GOGOUNOU |        113        1.87        6.02
         ALIBORI,KANDI |        238        3.94        9.96
      ALIBORI,KARIMAMA |         57        0.94       10.90
    ALIBORI,MALANVILLE |        118        1.95       12.86
       ALIBORI,SEGBANA |        116        1.92       14.77
     ATACORA,BOUKOUMBE |        116        1.92       16.69
         ATACORA,COBLY |         97        1.60       18.30
         ATACORA,KEROU |        164        2.71       21.01
       ATACORA,KOUANDE |        264        4.37       25.38
        ATACORA,MATERI |        190        3.14       28.52
    ATACORA,NATITINGOU |        210        3.47       32.00
ATACORA,OUASSA-PEHUNCO |        155        2.56       34.56
     ATACORA,TANGUIETA |        133        2.20       36.76
  ATACORA,TOUCOUNTOUNA |         58        0.96       37.72
      BORGOU,BEMBEREKE |        178        2.95       40.67
         BORGOU,KALALE |        135        2.23       42.90
         BORGOU,N'DALI |        211        3.49       46.39
          BORGOU,NIKKI |        157        2.60       48.99
        BORGOU,PARAKOU |        111        1.84       50.83
         BORGOU,PERERE |        256        4.24       55.06
        BORGOU,SINENDE |        158        2.61       57.68
      BORGOU,TCHAOUROU |        155        2.56       60.24
        COLLINES,BANTE |        301        4.98       65.22
  COLLINES,DASSA-ZOUME |        367        6.07       71.29
      COLLINES,GLAZOUE |        366        6.06       77.35
       COLLINES,OUESSE |        282        4.67       82.02
      COLLINES,SAVALOU |        182        3.01       85.03
         COLLINES,SAVE |        218        3.61       88.63
         DONGA,BASSILA |        146        2.42       91.05
         DONGA,COPARGO |         80        1.32       92.37
         DONGA,DJOUGOU |        281        4.65       97.02
           DONGA,OUAKE |        180        2.98      100.00
-----------------------+-----------------------------------
                 Total |      6,044      100.00

. 
.         gen urban=0

.         replace urban=1 if place=="ALIBORI,KANDI"|place=="ALIBORI,MALANVILLE"|place=="ATACORA,NATITINGOU"|place=="ATACORA,TANGUIETA"|place=="BORGOU,NIKKI"|place=="BORGOU,PARAKOU"|place=="BORGOU,TCHAOUROU"|place=="COLLINES,DASSA-ZOUME"|place=="COLLINE
> S,GLAZOUE"|place=="COLLINES,SAVE"|place=="DONGA,BASSILA"|place=="DONGA,DJOUGOU"
(2,500 real changes made)

. 
. ***Employment***
. 
.         gen occ=.
(6,044 missing values generated)

.         replace occ=1 if ac1_ado__2==1 
(699 real changes made)

.         replace occ=2 if ac1_ado__1==1 
(2,052 real changes made)

.         replace occ=3 if ac1_ado__3==1 | ac1_ado__4==1 | ac1_ado__5==1 | ac1_ado__6==1 | ac1_ado__7==1 | ac1_ado__8==1  | ac1_ado__9==1 | ac1_ado__10==1 | ac1_ado__11==1 
(1,144 real changes made)

.         replace occ=4 if ac1_ado__14==1 | ac1_ado__13==1| ac1_ado__12==1
(7 real changes made)

.         replace occ=5 if ac1_ado__n96==1
(63 real changes made)

.         label define occ  0 "None" 1 "Home" 2 "Agriculture" 3 "Modest Status" 4 "High Status" 5 "Other"

.         label values occ occ

. 
.         gen emp=0

.         replace emp=1 if occ!=.
(3,608 real changes made)

.         replace emp=0 if ac1_ado__0==1
(11 real changes made)

. 
. ***Education***
.         gen attend=1

.         gen enrol=1

.         //everyone attending (target audience) - cash transfers at school level
.         gen nvr_enrol=0

. 
. ***Marriage/children***
.         gen mar_age=ma5_ado1
(6,007 missing values generated)

.         replace mar_age=. if ma5_ado1<0
(9 real changes made, 9 to missing)

.         recode ma17a_ado (-99 -98 8 = .) (1 5 6 7 =0) (2 3 4 =1) (missing = .), gen(marital_status)
(6,044 differences between ma17a_ado and marital_status)

.         recode ma50_ado (-99 -98 = .) (1=1) (2=0), gen(child)
(6,005 differences between ma50_ado and child)

. 
.         gen nchild=0

.         replace nchild=sr6_ado if child==1
(21 real changes made, 2 to missing)

. 
. ***Items***
.         merge 1:1 ID_CM_MEN using "$DataPath\SWEDD Benin\CCT\MENAGE_Volet_2_clean.dta"
(label lm3 already defined)
(label lm5 already defined)
(label lm4 already defined)
(label lm6 already defined)
(label lm7_0 already defined)
(label lm8_0 already defined)
(label lm9 already defined)
(label lm10 already defined)
(label lm11 already defined)
(label lm12 already defined)
(label lm13 already defined)
(label lm14 already defined)
(label lm15 already defined)
(label lm16a already defined)
(label lm16 already defined)
(label lm17 already defined)
(label lm18 already defined)
(label lm19 already defined)
(label lm20 already defined)
(label lm21 already defined)
(label lm22 already defined)
(label id4 already defined)
(label volet already defined)
(label fille_echantillon already defined)
(label id14a_Men already defined)
(label id16a_Men already defined)
(label id2 already defined)
(label id3 already defined)
(label group already defined)

    Result                      Number of obs
    -----------------------------------------
    Not matched                           195
        from master                         0  (_merge==1)
        from using                        195  (_merge==2)

    Matched                             6,044  (_merge==3)
    -----------------------------------------

.         recode lo0__20 (0=0) (1=1), gen(mobile)
(0 differences between lo0__20 and mobile)

. 
. ***Financial Capital***
.         recode epc1_ado (-99 -98 =.) (1=1) (2=0), gen(save)
(5,549 differences between epc1_ado and save)

.         recode epc4_4ado (-99 -98 =.) (0=0) (1/800000 =1), gen(bank)
(116 differences between epc4_4ado and bank)

.         replace epc4_1ado=. if epc4_1ado<0
(33 real changes made, 33 to missing)

.         replace epc4_2ado=. if epc4_2ado<0
(66 real changes made, 66 to missing)

.         replace epc4_3ado=. if epc4_3ado<0
(68 real changes made, 68 to missing)

.         replace epc4_4ado=. if epc4_4ado<0
(73 real changes made, 73 to missing)

.         replace epc4_5ado=. if epc4_5ado<0
(73 real changes made, 73 to missing)

.         replace epc4_6ado=. if epc4_6ado<0
(73 real changes made, 73 to missing)

.         replace epc4_7ado=. if epc4_7ado<0
(74 real changes made, 74 to missing)

.         replace epc4_8ado=. if epc4_8ado<0
(68 real changes made, 68 to missing)

.         
.         egen double save_amount= rowtotal(epc4_1ado epc4_2ado epc4_3ado epc4_4ado epc4_5ado epc4_6ado epc4_7ado epc4_8ado)

.         replace save_amount=save_amount/200.413131288279
(437 real changes made)

. 
. ***Aspirations***
.         recode as8_ado (-99/-98=.) (0=0) (1 2 =1) (3 4 =2) (5 6 =3) (7=4), gen(asp_educ)
(6,007 differences between as8_ado and asp_educ)

.         label values asp_educ school

. 
.         gen mar_as_age= ma22_ado if ma22_ado>0
(1,317 missing values generated)

.         replace mar_as_age=88 if ma22_ado==-98
(610 real changes made)

. 
.         recode as12_ado (-99 -98 =.) (-96 = 5) (0=0) (1=1) (2/3=2) (4 6 7 8 9 10=3) (5 11=4), gen(asp_occ)
(5,936 differences between as12_ado and asp_occ)

.         label values asp_occ occ

. 
. ***Qualitative Score***
.         *Self-esteem
.                 recode ps1_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(5,145 changes made to ps1_ado)

.                 recode ps2_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(4,969 changes made to ps2_ado)

.                 recode ps3_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(4,739 changes made to ps3_ado)

.                 recode ps4_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(4,544 changes made to ps4_ado)

.                 recode ps5_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(4,737 changes made to ps5_ado)

.                 recode ps17_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(4,625 changes made to ps17_ado)

.                 recode ps18_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(4,692 changes made to ps18_ado)

.                 recode ps19_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(4,677 changes made to ps19_ado)

.                 recode ps30_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(4,554 changes made to ps30_ado)

.                 
.                 egen den = rownonmiss(ps1_ado ps2_ado ps3_ado ps4_ado ps5_ado ps17_ado ps18_ado ps19_ado ps30_ado)

.                 replace den=5*den
(6,028 real changes made)

.                 egen num= rowtotal(ps1_ado ps2_ado ps3_ado ps4_ado ps5_ado ps17_ado ps18_ado ps19_ado ps30_ado)

.                 
.                 gen se_score= num/den
(211 missing values generated)

.                 drop num den

.         *Locus of Control
.                 recode ps50_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(4,545 changes made to ps50_ado)

.                 recode ps49_ado (1=1) (2=2) (3=3) (4=4) (5=5) (missing = .) 
(0 changes made to ps49_ado)

.                 recode ps52_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(4,345 changes made to ps52_ado)

.                 recode ps56_ado (1=1) (2=2) (3=3) (4=4) (5=5) (missing = .) 
(0 changes made to ps56_ado)

.                 
.                 egen den= rownonmiss(ps50_ado ps49_ado ps52_ado ps56_ado)

.                 replace den=5*den
(6,028 real changes made)

.                 egen num= rowtotal(ps50_ado ps49_ado ps52_ado ps56_ado)

.                 gen lc_score=num/den
(211 missing values generated)

.                 drop num den

.         *Gender attitudes
.                 recode ma43_ado (-99 -98 99 =.) (1=0) (2/3=1) (missing = .) , gen(ga_educ)
(6,044 differences between ma43_ado and ga_educ)

.                 recode ma45_ado (-99 -98 99=.) (2=0) (1 3=1) (missing = .) , gen(ga_h)
(5,909 differences between ma45_ado and ga_h)

.                 
. // scores closer to 1 mean higher self esteem/locus of control/stronger feminist attitudes/equality     
. 
. **GBV
.         recode ge1_ado (1=1) (2=0) (-98 -99 = .), gen(gbv_5)
(5,913 differences between ge1_ado and gbv_5)

.         recode ge2_ado (1=1) (2=0) (-98 -99 = .), gen(gbv_3)
(5,868 differences between ge2_ado and gbv_3)

.         recode ge3_ado (1=1) (2=0) (-98 -99 = .), gen(gbv_1)
(5,628 differences between ge3_ado and gbv_1)

.         recode ge4_ado (1=1) (2=0) (-98 -99 = .), gen(gbv_2)
(5,461 differences between ge4_ado and gbv_2)

.         recode ge5_ado (1=1) (2=0) (-98 -99 = .), gen(gbv_4)
(5,833 differences between ge5_ado and gbv_4)

.         
.         gen gbv_simple=0 if gbv_1!=. | gbv_2!=. | gbv_3!=. | gbv_4!=. | gbv_5!=.  
(231 missing values generated)

.         replace gbv_simple=1 if  gbv_1==1 | gbv_2==1 | gbv_3==1 | gbv_4==1 | gbv_5==1  
(801 real changes made)

. 
. **SRH
.         recode sdr39_ado (1=1) (2=0) (-99 . =.) 
(2,645 changes made to sdr39_ado)

.         recode sr40_ado (1=1) (2=0) (-99 . =.)
(2,712 changes made to sr40_ado)

.         recode sr41_ado (1=1) (2=0) (-99 . =.)
(2,875 changes made to sr41_ado)

.         recode sr42_ado (1=1) (2=0) (-99 . =.)
(1,969 changes made to sr42_ado)

.         recode sr43_ado (1=1) (2=0) (-99 . =.)
(1,870 changes made to sr43_ado)

.         recode sr44_ado (1=1) (2=0) (-99 . =.)
(1,912 changes made to sr44_ado)

.         recode sr45_ado (1=1) (2=0) (-99 . =.)
(877 changes made to sr45_ado)

.         recode sr46_ado (1=1) (2=0) (-99 . =.)
(1,796 changes made to sr46_ado)

.         recode sr47_ado (1=1) (2=0) (-99 . =.)
(2,565 changes made to sr47_ado)

.         recode sr48_ado (1=1) (2=0) (-99 . =.)
(2,927 changes made to sr48_ado)

.         recode sr49_ado (1=1) (2=0) (-99 . =.)
(2,895 changes made to sr49_ado)

.         recode sr50_ado (1=1) (2=0) (-99 . =.)
(2,818 changes made to sr50_ado)

.         recode sr51_ado (1=1) (2=0) (-99 . =.)
(2,966 changes made to sr51_ado)

.         recode sr52_ado (1=1) (2=0) (-99 . =.)
(2,969 changes made to sr52_ado)

.         recode sr53a_ado (1=1) (2=0) (-99 . =.)
(2,949 changes made to sr53a_ado)

.         
.         gen know_contraception = .
(6,239 missing values generated)

.         replace know_contraception=0 if sdr39_ado==0 |  sr40_ado==0 |  sr41_ado==0 |  sr42_ado==0 |  sr43_ado==0 |  sr44_ado==0 |  sr45_ado==0 |  sr46_ado==0 |  sr47_ado==0 |  sr48_ado==0 |  sr49_ado==0 |  sr50_ado==0 |  sr51_ado==0 |  sr52_ado==0 | 
>  sr53a_ado==0
(3,009 real changes made)

.         replace know_contraception=1 if sdr39_ado==1 | sr40_ado==1 | sr41_ado==1 | sr42_ado==1 | sr43_ado==1 | sr44_ado==1 | sr45_ado==1 | sr46_ado==1 | sr47_ado==1 | sr48_ado==1 | sr49_ado==1 | sr50_ado==1 | sr51_ado==1 | sr52_ado==1 | sr53a_ado==1
(2,340 real changes made)

.         
. keep year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ se_score lc_score ga_educ ga_h gbv*  know_contraception

. 
. compress year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ know_contraception
  variable year was float now int
  variable round was float now byte
  variable urban was float now byte
  variable emp was float now byte
  variable nvr_enrol was float now byte
  variable attend was float now byte
  variable mar_age was float now byte
  variable nchild was float now byte
  variable mar_as_age was float now byte
  variable know_contraception was float now byte
  variable age was double now byte
  (224,604 bytes saved)

. 
. save "$CleanDataPath\clean-cct-benin.dta", replace
file C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Data/clean\clean-cct-benin.dta saved

. 
end of do-file

.         clear all

.         do "$Do\Benin_ss.do"

. use "$DataPath\SWEDD Benin\Safespaces\ADO_Volet_1_clean.dta"

. 
. ***Survey chars***
.         gen year= 2022

.         gen round =0

.         gen str source= "SWEDD_Benin_SS"

.         gen country = "BEN"

. 
. ***Age & Urban/Rural***
.         rename lm6_ADO age

.         drop if age<10 | age>19
(1,647 observations deleted)

.         drop if age==.
(0 observations deleted)

. 
.         decode id4, generate(id_4)

.         gen place=id_4+","+id5

.         tab place

                 place |      Freq.     Percent        Cum.
-----------------------+-----------------------------------
     ALIBORI,BANIKOARA |        153        3.52        3.52
      ALIBORI,GOGOUNOU |        122        2.81        6.33
         ALIBORI,KANDI |        135        3.11        9.44
      ALIBORI,KARIMAMA |        160        3.68       13.12
    ALIBORI,MALANVILLE |        161        3.71       16.83
       ALIBORI,SEGBANA |        132        3.04       19.87
     ATACORA,BOUKOUMBE |        127        2.92       22.79
         ATACORA,COBLY |        116        2.67       25.46
         ATACORA,KEROU |        156        3.59       29.05
       ATACORA,KOUANDE |        135        3.11       32.16
        ATACORA,MATERI |        126        2.90       35.06
    ATACORA,NATITINGOU |        119        2.74       37.80
ATACORA,OUASSA-PEHUNCO |        128        2.95       40.75
     ATACORA,TANGUIETA |        138        3.18       43.92
  ATACORA,TOUCOUNTOUNA |        149        3.43       47.35
      BORGOU,BEMBEREKE |        132        3.04       50.39
         BORGOU,KALALE |        144        3.31       53.71
         BORGOU,N'DALI |        144        3.31       57.02
          BORGOU,NIKKI |        110        2.53       59.55
        BORGOU,PARAKOU |        130        2.99       62.55
         BORGOU,PERERE |        127        2.92       65.47
        BORGOU,SINENDE |        115        2.65       68.12
      BORGOU,TCHAOUROU |        151        3.48       71.59
        COLLINES,BANTE |        117        2.69       74.29
  COLLINES,DASSA-ZOUME |        132        3.04       77.33
      COLLINES,GLAZOUE |        137        3.15       80.48
       COLLINES,OUESSE |        117        2.69       83.17
      COLLINES,SAVALOU |        124        2.85       86.03
         COLLINES,SAVE |        150        3.45       89.48
         DONGA,BASSILA |        109        2.51       91.99
         DONGA,COPARGO |        119        2.74       94.73
         DONGA,DJOUGOU |        132        3.04       97.77
           DONGA,OUAKE |         97        2.23      100.00
-----------------------+-----------------------------------
                 Total |      4,344      100.00

. 
.         gen urban=0

.         replace urban=1 if place=="ALIBORI,KANDI"|place=="ALIBORI,MALANVILLE"|place=="ATACORA,NATITINGOU"|place=="ATACORA,TANGUIETA"|place=="BORGOU,NIKKI"|place=="BORGOU,PARAKOU"|place=="BORGOU,TCHAOUROU"|place=="COLLINES,DASSA-ZOUME"|place=="COLLINE
> S,GLAZOUE"
(1,213 real changes made)

. 
. ***Employment***
. 
.         gen occ=.
(4,344 missing values generated)

.         replace occ=1 if ac1_ado__2==1 
(592 real changes made)

.         replace occ=2 if ac1_ado__1==1 
(2,609 real changes made)

.         replace occ=3 if ac1_ado__3==1 | ac1_ado__4==1 | ac1_ado__5==1 | ac1_ado__6==1 | ac1_ado__7==1 | ac1_ado__8==1  | ac1_ado__9==1 | ac1_ado__10==1 | ac1_ado__11==1 
(1,368 real changes made)

.         replace occ=4 if ac1_ado__14==1 | ac1_ado__13==1| ac1_ado__12==1
(4 real changes made)

.         replace occ=5 if ac1_ado__n96==1
(40 real changes made)

.         label define occ  0 "None" 1 "Home" 2 "Agriculture" 3 "Modest Status" 4 "High Status" 5 "Other"

.         label values occ occ

. 
.         gen emp=0

.         replace emp=1 if occ!=.
(4,207 real changes made)

.         replace emp=0 if ac1_ado__0==1
(0 real changes made)

. 
. ***Education***
.         gen attend=0

.         //ed3_ado has no one attending (target audience)
. 
.         gen nvr_enrol=0

.         replace nvr_enrol=1 if ed1_ado==1
(2,034 real changes made)

.         replace nvr_enrol=. if ed1_ado<0
(5 real changes made, 5 to missing)

. 
. ***Marriage/children***
.         gen mar_age=ma5_ado1
(4,023 missing values generated)

.         replace mar_age=. if ma5_ado1<0
(36 real changes made, 36 to missing)

. 
.         recode ma17a_ado (-99 -98 = .) (1 5 6 7 =0) (2 3 4 =1), gen(marital_status)
(4,344 differences between ma17a_ado and marital_status)

. 
.         recode sr28_ado (-99 -98 = .) (1=1) (2=0), gen(pregnant)
(2,173 differences between sr28_ado and pregnant)

. 
.         recode ma50_ado (-99 -98 = .) (1=1) (2=0), gen(child)
(4,056 differences between ma50_ado and child)

. 
.         gen nchild=0

.         replace nchild=sr6_ado if child==1
(286 real changes made, 50 to missing)

. 
. ***Items***
.         merge 1:1 id8c using "$DataPath\SWEDD Benin\Safespaces\MENAGE_Volet_1_clean.dta"
(label lm3 already defined)
(label lm5 already defined)
(label lm6 already defined)
(label lm7_0 already defined)
(label lm8_0 already defined)
(label lm9 already defined)
(label lm10 already defined)
(label lm11 already defined)
(label lm12 already defined)
(label lm13 already defined)
(label lm14 already defined)
(label lm15 already defined)
(label lm16a already defined)
(label lm16 already defined)
(label lm17 already defined)
(label lm18 already defined)
(label lm19 already defined)
(label lm20 already defined)
(label lm21 already defined)
(label lm22 already defined)
(label id4 already defined)
(label id7 already defined)
(label id14a_Men already defined)
(label id16a_Men already defined)
(label id2 already defined)
(label id3 already defined)
(label groupe already defined)

    Result                      Number of obs
    -----------------------------------------
    Not matched                         1,647
        from master                         0  (_merge==1)
        from using                      1,647  (_merge==2)

    Matched                             4,344  (_merge==3)
    -----------------------------------------

.         recode lo0__20 (0=0) (1=1), gen(mobile)
(0 differences between lo0__20 and mobile)

. 
. ***Financial Capital***
.         recode epc1_ado (-99 -98 =.) (1=1) (2=0), gen(save)     
(3,866 differences between epc1_ado and save)

.         replace epc4_1ado=. if epc4_1ado<0
(52 real changes made, 52 to missing)

.         replace epc4_2ado=. if epc4_2ado<0
(73 real changes made, 73 to missing)

.         replace epc4_3ado=. if epc4_3ado<0
(68 real changes made, 68 to missing)

.         replace epc4_4ado=. if epc4_4ado<0
(66 real changes made, 66 to missing)

.         replace epc4_5ado=. if epc4_5ado<0
(63 real changes made, 63 to missing)

.         replace epc4_6ado=. if epc4_6ado<0
(68 real changes made, 68 to missing)

.         replace epc4_7ado=. if epc4_7ado<0
(59 real changes made, 59 to missing)

.         replace epc4_8ado=. if epc4_8ado<0
(66 real changes made, 66 to missing)

.         
.         egen double save_amount= rowtotal(epc4_1ado epc4_2ado epc4_3ado epc4_4ado epc4_5ado epc4_6ado epc4_7ado epc4_8ado)

.         replace save_amount=save_amount/200.413131288279
(395 real changes made)

. 
.                 
. ***Aspirations***
.         recode as8_ado (-99/-98=.) (0=0) (1 2 =1) (3 4 =2) (5 6 =3) (7=4), gen(asp_educ)
(4,344 differences between as8_ado and asp_educ)

. 
.         label values asp_educ school

. 
.         gen mar_as_age= ma22_ado if ma22_ado>0
(3,173 missing values generated)

.         replace mar_as_age=88 if ma22_ado==-98
(508 real changes made)

. 
.         recode as12_ado (-99 -98 =.) (-96 = 5) (0=0) (1=1) (2/3=2) (4 6 7 8 9 10=3) (5 11=4), gen(asp_occ)
(3,317 differences between as12_ado and asp_occ)

.         label values asp_occ occ

. 
. ***Qualitative Score***
.         *Self-esteem
.                 recode ps1_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,736 changes made to ps1_ado)

.                 recode ps2_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,609 changes made to ps2_ado)

.                 recode ps3_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,553 changes made to ps3_ado)

.                 recode ps4_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,245 changes made to ps4_ado)

.                 recode ps5_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,475 changes made to ps5_ado)

.                 recode ps17_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,312 changes made to ps17_ado)

.                 recode ps18_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,408 changes made to ps18_ado)

.                 recode ps19_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,414 changes made to ps19_ado)

.                 recode ps30_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,433 changes made to ps30_ado)

.                 
.                 egen den = rownonmiss(ps1_ado ps2_ado ps3_ado ps4_ado ps5_ado ps17_ado ps18_ado ps19_ado ps30_ado)

.                 replace den=5*den
(4,344 real changes made)

.                 egen num= rowtotal(ps1_ado ps2_ado ps3_ado ps4_ado ps5_ado ps17_ado ps18_ado ps19_ado ps30_ado)

.                 
.                 gen se_score= num/den
(1,647 missing values generated)

.                 drop num den

.         *Locus of Control
.                 recode ps50_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,400 changes made to ps50_ado)

.                 recode ps49_ado (1=1) (2=2) (3=3) (4=4) (5=5) (missing = .) 
(0 changes made to ps49_ado)

.                 recode ps52_ado (1=5) (2=4) (3=3) (4=2) (5=1) (missing = .) 
(3,198 changes made to ps52_ado)

.                 recode ps56_ado (1=1) (2=2) (3=3) (4=4) (5=5) (missing = .) 
(0 changes made to ps56_ado)

.                 
.                 egen den= rownonmiss(ps50_ado ps49_ado ps52_ado ps56_ado)

.                 replace den=5*den
(4,344 real changes made)

.                 egen num= rowtotal(ps50_ado ps49_ado ps52_ado ps56_ado)

.                 gen lc_score=num/den
(1,647 missing values generated)

.                 drop num den

.         *Gender attitudes
.                 recode ma43_ado (-99 -98 =.) (1=0) (2/3=1) (missing = .) , gen(ga_educ)
(4,344 differences between ma43_ado and ga_educ)

.                 recode ma45_ado (-99 -98 =.) (2=0) (1 3=1) (missing = .) , gen(ga_h)
(4,200 differences between ma45_ado and ga_h)

. // scores closer to 1 mean higher self esteem/locus of control/stronger feminist attitudes      
. 
. **GBV
.         recode ge1_ado (1=1) (2=0) (-98 -99 = .), gen(gbv_5)
(4,260 differences between ge1_ado and gbv_5)

.         recode ge2_ado (1=1) (2=0) (-98 -99 = .), gen(gbv_3)
(4,138 differences between ge2_ado and gbv_3)

.         recode ge3_ado (1=1) (2=0) (-98 -99 = .), gen(gbv_1)
(4,004 differences between ge3_ado and gbv_1)

.         recode ge4_ado (1=1) (2=0) (-98 -99 = .), gen(gbv_2)
(4,049 differences between ge4_ado and gbv_2)

.         recode ge5_ado (1=1) (2=0) (-98 -99 = .), gen(gbv_4)
(4,160 differences between ge5_ado and gbv_4)

.         
.         gen gbv_simple=0 if gbv_1!=. | gbv_2!=. | gbv_3!=. | gbv_4!=. | gbv_5!=.  
(1,669 missing values generated)

.         replace gbv_simple=1 if  gbv_1==1 | gbv_2==1 | gbv_3==1 | gbv_4==1 | gbv_5==1  
(590 real changes made)

. 
. **SRH
.         recode sdr39_ado (1=1) (2=0) (-99 . =.) 
(1,948 changes made to sdr39_ado)

.         recode sr40_ado (1=1) (2=0) (-99 . =.)
(1,981 changes made to sr40_ado)

.         recode sr41_ado (1=1) (2=0) (-99 . =.)
(2,081 changes made to sr41_ado)

.         recode sr42_ado (1=1) (2=0) (-99 . =.)
(1,301 changes made to sr42_ado)

.         recode sr43_ado (1=1) (2=0) (-99 . =.)
(1,172 changes made to sr43_ado)

.         recode sr44_ado (1=1) (2=0) (-99 . =.)
(1,350 changes made to sr44_ado)

.         recode sr45_ado (1=1) (2=0) (-99 . =.)
(970 changes made to sr45_ado)

.         recode sr46_ado (1=1) (2=0) (-99 . =.)
(1,716 changes made to sr46_ado)

.         recode sr47_ado (1=1) (2=0) (-99 . =.)
(1,913 changes made to sr47_ado)

.         recode sr48_ado (1=1) (2=0) (-99 . =.)
(2,090 changes made to sr48_ado)

.         recode sr49_ado (1=1) (2=0) (-99 . =.)
(2,114 changes made to sr49_ado)

.         recode sr50_ado (1=1) (2=0) (-99 . =.)
(1,989 changes made to sr50_ado)

.         recode sr51_ado (1=1) (2=0) (-99 . =.)
(2,184 changes made to sr51_ado)

.         recode sr52_ado (1=1) (2=0) (-99 . =.)
(2,181 changes made to sr52_ado)

.         recode sr53a_ado (1=1) (2=0) (-99 . =.)
(2,149 changes made to sr53a_ado)

.         
.         gen know_contraception = .
(5,991 missing values generated)

.         replace know_contraception=0 if sdr39_ado==0 |  sr40_ado==0 |  sr41_ado==0 |  sr42_ado==0 |  sr43_ado==0 |  sr44_ado==0 |  sr45_ado==0 |  sr46_ado==0 |  sr47_ado==0 |  sr48_ado==0 |  sr49_ado==0 |  sr50_ado==0 |  sr51_ado==0 |  sr52_ado==0 | 
>  sr53a_ado==0
(2,223 real changes made)

.         replace know_contraception=1 if sdr39_ado==1 | sr40_ado==1 | sr41_ado==1 | sr42_ado==1 | sr43_ado==1 | sr44_ado==1 | sr45_ado==1 | sr46_ado==1 | sr47_ado==1 | sr48_ado==1 | sr49_ado==1 | sr50_ado==1 | sr51_ado==1 | sr52_ado==1 | sr53a_ado==1
(1,600 real changes made)

.         
. keep year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ se_score lc_score ga_educ ga_h gbv* know_contraception 

. 
. compress year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ know_contraception 
  variable year was float now int
  variable round was float now byte
  variable urban was float now byte
  variable emp was float now byte
  variable nvr_enrol was float now byte
  variable attend was float now byte
  variable mar_age was float now byte
  variable nchild was float now byte
  variable mar_as_age was float now byte
  variable know_contraception was float now byte
  variable age was double now byte
  (215,676 bytes saved)

. 
. save "$CleanDataPath\clean-ss-benin.dta", replace
file C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Data/clean\clean-ss-benin.dta saved

. 
end of do-file

.         clear all

.         do "$Do\SWEDD_H.do"

. use "$DataPath\SWEDD\BLSWEDDado(en).dta" 

. 
. ***Survey chars***
.         gen year= 2017

.         gen round =0

.         gen source= "SWEDD "+country

. 
. ***Age & Urban/Rural*** 
.         //urban already coded
.         rename age_ado age

.         drop if age<10 | age>19
(13,518 observations deleted)

.         drop if age==.
(0 observations deleted)

.         //obs=22989
. 
. ***Employment***
.         gen emp=(econ_any!=0) if econ_any!=.        
(59 missing values generated)

.         
. ***Education***
.         gen attend=(in_school==1) if in_school!=.
(26 missing values generated)

.         gen nvr_enrol=(ever_school==0) if ever_school!=.
(64 missing values generated)

. 
. ***Marriage/children***
.         gen marital_status=(adomarstat_curr==1) if adomarstat_curr!=.
(3,752 missing values generated)

.         rename children child

.         gen nchild=.
(22,989 missing values generated)

. 
. 
. ***Items***
.         gen mobile=(asset_yes_19==1)

. 
. ***Financial Capital***
.         rename save_money save

.         rename amount_saved_PPP save_amount

.         
. ***Aspirations***
.         recode asp_edu_own (0=0) (1/2=1) (3/4=2) (5=3) (.=.) , gen(asp_educ)
(15,067 differences between asp_edu_own and asp_educ)

.         rename wish_mar_age mar_as_age

.         label define mar_as 77 "Already Married"  88 "Don't Know" 98 "Dont want to get married"

.         label values mar_as_age mar_as

.         rename asp_prof_ideal asp_occ

.         label values asp_occ occ

. 
. ***Qualitative Score***
.         *Self-esteem
.                 recode sef_1 (1=4) (2=3) (3=4) (4=1) (missing = .)
(22,874 changes made to sef_1)

.                 recode sef_2 (1=4) (2=3) (3=4) (4=1) (missing = .)
(22,838 changes made to sef_2)

.                 recode sef_3 (1=4) (2=3) (3=4) (4=1) (missing = .)
(22,848 changes made to sef_3)

.                 recode sef_4 (1=4) (2=3) (3=4) (4=1) (missing = .)
(22,818 changes made to sef_4)

.                 recode sef_5 (1=4) (2=3) (3=4) (4=1) (missing = .)
(22,787 changes made to sef_5)

.                 recode sef_6 (1=4) (2=3) (3=4) (4=1) (missing = .)
(22,836 changes made to sef_6)

.                 recode sef_8 (1=4) (2=3) (3=4) (4=1) (missing = .)
(22,799 changes made to sef_8)

.                 
.                 egen den=rownonmiss(sef_1 sef_2 sef_3 sef_4 sef_5 sef_6 sef_8)

.                 replace den=4*den
(22,909 real changes made)

.                 egen num=rowtotal(sef_1 sef_2 sef_3 sef_4 sef_5 sef_6 sef_8)

.                 gen se_score= num/den
(80 missing values generated)

.                 drop num den

.                 
.         *Locus of Control
.                 recode loc_1 (1=1) (2=2) (3=3) (4=4) (missing = .)
(0 changes made to loc_1)

.                 recode loc_2 (1=4) (2=3) (3=4) (4=1) (missing = .)
(18,195 changes made to loc_2)

.                 recode loc_10 (1=1) (2=2) (3=3) (4=4) (missing = .)
(0 changes made to loc_10)

.                 recode loc_19 (1=4) (2=3) (3=4) (4=1) (missing = .)
(18,194 changes made to loc_19)

.                 
.                 egen den=rownonmiss(loc_2 loc_4 loc_10 loc_19)

.                 replace den=4*den
(18,195 real changes made)

.                 egen num=rowtotal(loc_2 loc_4 loc_10 loc_19)

.                 gen lc_score= num/den
(4,794 missing values generated)

.                 drop num den

.                 
.         *Gender attitudes
.                 recode ge_1 (1=1) (2/3=2) (missing = .), gen(ga_educ)
(8,779 differences between ge_1 and ga_educ)

.                 recode ge_3 (2=1) (1/3=2) (missing = .), gen(ga2)
(22,921 differences between ge_3 and ga2)

.                 recode ge_4 (2=1) (1/3=2) (missing = .), gen(ga3)
(22,921 differences between ge_4 and ga3)

.                 recode ge_5 (2=1) (1/3=2) (missing = .), gen(ga4)
(22,921 differences between ge_5 and ga4)

.                 recode ge_5 (2=1) (1/3=2) (missing = .), gen(ga5)
(22,921 differences between ge_5 and ga5)

.                 recode ge_7 (2=1) (1/3=2) (missing = .), gen(ga6)
(22,921 differences between ge_7 and ga6)

.                 egen num= rowtotal(ga2 ga3 ga4 ga5 ga6)

.                 egen den= rownonmiss(ga2 ga3 ga4 ga5 ga6)

.                 replace den=4*den
(22,921 real changes made)

.                 gen ga_h= num/den
(68 missing values generated)

.                 drop num den

.                 
.                 replace ga_educ=ga_educ-1 if ga_educ!=.
(22,921 real changes made)

.                 
.         
. // scores closer to 1 mean higher self esteem/locus of control/stronger feminist attitudes 
. 
. **GBV
.         rename gen_3 gbv_1

.         rename gen_4 gbv_2

.         rename gen_2 gbv_3

.         rename gen_5 gbv_4

.         rename gen_1 gbv_5

.         
.         gen gbv_simple=0 if gbv_1!=. | gbv_2!=. | gbv_3!=. | gbv_4!=. | gbv_5!=.  
(8,069 missing values generated)

.         replace gbv_simple=1 if  gbv_1==1 | gbv_2==1 | gbv_3==1 | gbv_4==1 | gbv_5==1  
(7,150 real changes made)

.         
.         rename gen_9 gbv_x

.         
. **SRH
. rename know_modern_method know_contraception

.         
. keep year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ se_score lc_score ga_h ga_educ gbv_simple know_contraception 

. 
. compress year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ
  variable year was float now int
  variable round was float now byte
  variable urban was float now byte
  variable age was float now byte
  variable emp was float now byte
  variable nvr_enrol was float now byte
  variable attend was float now byte
  variable mar_age was float now byte
  variable marital_status was float now byte
  variable child was float now byte
  variable nchild was float now byte
  variable mobile was float now byte
  variable save was float now byte
  variable asp_educ was float now byte
  variable mar_as_age was float now byte
  variable asp_occ was double now byte
  (1,172,439 bytes saved)

. 
. save "$CleanDataPath\clean-swedd.dta", replace
file C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Data/clean\clean-swedd.dta saved

. 
. 
. 
. 
. 
. 
. 
end of do-file

.         clear all

.         do "$Do\TZ_SS"

. use "$DataPath\TZ_Safe\TZ_PASS-Baseline_ee.dta"

. 
. ***Survey chars***
.         gen str country = "TZA"

.         gen year=2016

.         gen round=0

.         gen str source= "TZA_SafeSex"

. 
. ***Age & Urban/Rural*** 
.         gen urban=0

.         drop if age<10 | age>19
(823 observations deleted)

.         drop if age==.
(0 observations deleted)

. 
. ***Employment***
.         gen emp=0

.         replace emp=(s5_b_1_a_1==10 | s5_b_1_a_1==11) + (s5_b_2_a_1==10 |s5_b_2_a_1==11) + (s5_b_3_a_1==10 |s5_b_3_a_1==11) + (s5_b_3a_a_1==10 |s5_b_3a_a_1==11) + (s5_b_4_a_1==10 |s5_b_4_a_1==11) + (s5_b_5_a_1==10 |s5_b_5_a_1==11) + (s5_b_6_a_1==10 |
> s5_b_6_a_1==11) + (s5_b_7_a_1==10 |s5_b_7_a_1==11) + (s5_b_8_a_1==10 |s5_b_8_a_1==11) + (s5_b_9_a_1==10 |s5_b_9_a_1==11) + (s5_b_10_a_1==10 |s5_b_10_a_1==11) + (s5_b_11_a_1==10 |s5_b_11_a_1==11) + (s5_b_12_a_1==10 |s5_b_12_a_1==11) + (s5_b_13_a_1==10
>  |s5_b_13_a_1==11) + (s5_b_14_a_1==10 |s5_b_14_a_1==11) + (s5_b_15_a_1==10 |s5_b_15_a_1==11) + (s5_b_16_a_1==10 |s5_b_16_a_1==11) + (s5_b_17_a_1==10 |s5_b_17_a_1==11) + (s5_b_18_a_1==10 |s5_b_18_a_1==11) + (s5_b_19_a_1==10 |s5_b_19_a_1==11) + (s5_b_2
> 0_a_1==10 |s5_b_20_a_1==11) + (s5_b_21_a_1==10 |s5_b_21_a_1==11) + (s5_b_22_a_1==10 |s5_b_22_a_1==11) + (s5_b_23_a_1==10 | s5_b_23_a_1==11)
(424 real changes made)

. replace emp=1 if emp>0
(181 real changes made)

.         
. 
.         gen occode=substr(s9_array1,1,2)
(3,159 missing values generated)

.         destring occode, generate(occode1)
occode: all characters numeric; occode1 generated as byte
(3159 missing values generated)

.         replace emp=1 if occode1!=. & emp==0
(173 real changes made)

. 
.         rename occode1 occ

.         recode occ (1 3=2) (4=1) (2=4) (3 5 6 =3)
(243 changes made to occ)

.         label define occ  0 "None" 1 "Home" 2 "Agriculture" 3 "Modest Status" 4 "High Status" 5 "Other"

.         label values occ occ

. 
. ***Education***
.         gen enrol=(s5_1==1 | s5_1==4)

.         gen nvr_enrol=(s5_1==3)

.         gen attend=enrol

. 
. ***Marriage/children***
.         recode s6_1 (1=1) (4=1) (2/3=0) (5=0), gen(marital_status)
(3,336 differences between s6_1 and marital_status)

.         gen child=(child_num!=0)

.         rename child_num nchild

.         gen mar_age=.
(3,402 missing values generated)

. 
. ***Items***
.         gen mobile=.
(3,402 missing values generated)

. 
. ***Financial Capital***
.         gen save=0

.         gen double save_amount=s14_1/848.679565429688

.         replace save=1 if s14_1!=0
(479 real changes made)

. 
. ***Aspirations***
.         recode s5_6 (.=.) (0=0) (1/5 = 1) (6/8 = 2) (9/12 = 3) (13/19 = 4), gen(asp_educ)
(2,365 differences between s5_6 and asp_educ)

.         recode s5_22 (.=.) (0=0) (1/5 = 1) (6/8 = 2) (9/12 = 3) (13/19 = 4)
(150 changes made to s5_22)

.         recode s5_32 (.=.) (0=0) (1/5 = 1) (6/8 = 2) (9/12 = 3) (13/19 = 4)
(24 changes made to s5_32)

.         recode s5_40 (.=.) (0=0) (1/5 = 1) (6/8 = 2) (9/12 = 3) (13/19 = 4)
(862 changes made to s5_40)

.         gen other= s5_22
(3,252 missing values generated)

.         replace other=s5_32 if other==.
(24 real changes made)

.         replace other=s5_40 if other==.
(863 real changes made)

.         replace asp_educ=other if other!=.
(1,037 real changes made)

.         replace asp_educ=1 if asp_educ==0
(1 real change made)

.         drop other

. 
.         gen mar_as_age=.
(3,402 missing values generated)

.         
.         gen asp_occ=.
(3,402 missing values generated)

. 
. ***Qualitative Score***
.         *Self-esteem
.         gen se_score=. 
(3,402 missing values generated)

.         *Locus of Control
.         gen lc_score=.
(3,402 missing values generated)

.         *Gender attitudes
.         gen ga_score=.
(3,402 missing values generated)

. // scores closer to 1 mean higher self esteem/locus of control/stronger feminist/equal attitudes 
. 
. keep year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ se_score lc_score ga_score 

. 
. compress year round source country urban age emp nvr_enrol attend mar_age marital_status child nchild mobile save save_amount asp_educ mar_as_age asp_occ
  variable year was float now int
  variable round was float now byte
  variable urban was float now byte
  variable age was float now byte
  variable emp was float now byte
  variable nvr_enrol was float now byte
  variable attend was float now byte
  variable mar_age was float now byte
  variable child was float now byte
  variable nchild was float now byte
  variable mobile was float now byte
  variable save was float now byte
  variable mar_as_age was float now byte
  variable asp_occ was float now byte
  (139,482 bytes saved)

. 
. save "$CleanDataPath\clean_TZ.dta", replace
file C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Data/clean\clean_TZ.dta saved

. 
. 
end of do-file

.         clear all

. 
. //Step 3: Create Harmonized Baseline Data
.         use "$CleanDataPath\clean-swedd.dta"

.         append using "$CleanDataPath\clean_AGEP_Girls_Round4.dta" "$CleanDataPath\clean_AGIK_combined.dta" "$CleanDataPath\clean-agile.dta" "$CleanDataPath\clean-cct-benin.dta" "$CleanDataPath\clean-ss-benin.dta" "$CleanDataPath\clean_TZ.dta"
(variable save_amount was float, now double to accommodate using data's values)
(label mar_as already defined)
(label mar_as already defined)
(label marital_status already defined)
(label mar_as already defined)
(label marital_status already defined)
(variable source was str9, now str15 to accommodate using data's values)
(label occ already defined)
(label lm6 already defined)
(label occ already defined)

. 
. //Step 4: Correct all the labels:
.         //define
.         //label define school 0 "Kindergarten" 1 "Primary" 2 "Secondary" 3 "High School" 4 "University"
.         label define mar_as_ 77 "Already Married"  88 "Don't Know" 98 "Dont want to get married"

.         label define school -1 "None" 0 "Kindergarten" 1 "Primary" 2 "Secondary" 3 "High School" 4 "University"

.         //label define marital_status 0 "Unmarried" 1 "Married"
.         //label define occ  0 "None" 1 "Home" 2 "Agriculture" 3 "Modest Status" 4 "High Status" 5 "Other"
.         label define yn  0 "No" 1 "Yes"

.         label define urb 0 "Rural" 1 "Urban"

.                 
.         //apply
.         
.         label values urban urb

.         label values asp_educ school

.         replace mar_as_age=77 if marital_status==1
(8,251 real changes made)

.         label values mar_as_age mar_as_

.         label values marital_status marital_status 

.         label values occ asp_occ occ

.         label variable year "Year IE (round) was conducted"

.         label variable round "Round of IE (0 refers to baseline)"

.         label variable source "IE Name"

.         label variable emp "Employed in the past year?"

.         label variable attend "Current school attendance"

.         label variable asp_occ "Ideal occupation would have liked to have"

.         label variable nvr_enrol "Adolescent never enroled in school"

.         label variable marital_status "Current marital status"

.         label variable nchild "Number of children"

.         label variable mobile "Hh/adolescent possesses: a mobile phone?"

.         label variable asp_educ "Education desired to achieve"

.         label variable se_score "Self-efficacy score"

.         label variable lc_score "Locus of control score"

.         label variable ga_h "Gender attitudes score: Household chores"

.         label variable ga_educ "Gender attitudes score: Equal education for girls and boys"

.         label variable gbv_1 "GBV attitude: ok to hit if she goes out without telling him?"

.         label variable gbv_2 "GBV attitude: ok to hit if she neglects the children?"

.         label variable gbv_3 "GBV attitude: ok to hit if she argues with him?"

.         label variable gbv_4 "GBV attitude: ok to hit if she refuses to have sex with him?"

.         label variable gbv_5 "GBV attitude: ok to hit if she burns the food?"

.         label variable gbv_simple "GBV attitude: ok to hit for any reason"

.         label values gbv_* mobile child emp yn

. 
. numlabel, add

. 
. //Step 5: Ensure variables are correctly defined:
.         //marriage age is blank if girl is not married
.                 replace mar_age=. if marital_status==0
(1,446 real changes made, 1,446 to missing)

.                 replace mar_as_age=. if marital_status==1 | mar_as_age>=77
(12,337 real changes made, 12,337 to missing)

.                 order source country age 

.                 
.         //Correct Savings for SWEDD BFA:
.                 replace save=1 if save_amount>0 & source=="SWEDD BFA"
(507 real changes made)

.                 replace save=0 if save_amount==0 & source=="SWEDD BFA"
(3,821 real changes made)

.                 winsor2 save_amount, cuts (1 99) by(source)

.         
.         //Create dummies for aspirational occupation and education:
.                 recode asp_educ (0/2=0) (3/4 =1) (missing = .), gen(asp_educ_dummy)
(42,660 differences between asp_educ and asp_educ_dummy)

.                 recode asp_occ (0/3 5=0) (4=1) (missing = .), gen(asp_occ_dummy)
(41,005 differences between asp_occ and asp_occ_dummy)

.                 replace asp_occ_dummy=0 if asp_occ!=4 & asp_occ!=. & country=="BEN"
(0 real changes made)

.                 replace asp_occ_dummy=1 if asp_occ==4 & asp_occ!=. & country=="BEN"
(0 real changes made)

.         
.         //Age group dummy
.                 gen agegp=(age>14)

.         
.         gen off=1 if save==1 & save_amount_w==0
(52,444 missing values generated)

.         gen withoutzeros_save_amount=save_amount_w if off==.
(14,050 missing values generated)

.         winsor2 withoutzeros_save_amount, cuts (1 99) by(source)

.         drop withoutzeros_save_amount

.         rename withoutzeros_save_amount_w withoutzeros_save_amount

.                 
.         //save missing values as .
.         replace child=. if child==99
(18 real changes made, 18 to missing)

.         replace mar_age=. if mar_age==88
(1 real change made, 1 to missing)

.         replace nchild=. if nchild<0
(1 real change made, 1 to missing)

.         replace asp_educ=. if asp_educ<0
(0 real changes made)

.         drop if age==.
(1,842 observations deleted)

.         
. drop off

. 
. save "$CleanDataPath\Harmonized_baseline_final.dta", replace
file C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Data/clean\Harmonized_baseline_final.dta saved

. 
.                         
. 
.         
. 
end of do-file

. do "${code}/2_TableS2.1.do"

. //Step 1: Load the pooled data
.         *Enter path below, and remove the * at the start of the line:
.         use "${CleanDataPath}/Harmonized_baseline_final.dta", clear

. 
. //Step 2: Define weights for the "weighted pooled average" column:
. egen source_num=group(source)

. cap program drop run_chunk

.         program define run_chunk
  1.                 syntax varlist(min=1 max=1)
  2.                         cap drop total_obs weight std_weight
  3.                         egen total_obs = count(source_num) if `varlist' < ., by(source_num)
  4.                         gen weight = 1/total_obs if `varlist' < .
  5.                         sum weight if `varlist' < ., meanonly
  6.                         gen std_weight = weight/r(sum) if `varlist' < .
  7.         end

. 
. //Step 3: Generate Estimates
.         *Column 1: Number of observations
.                 gen rural=1-urban
(26 missing values generated)

.                 tabstat agegp rural marital_status mar_age child nvr_enrol attend know_contraception save withoutzeros_save_amount mobile asp_educ_dummy asp_occ_dummy mar_as_age se_score lc_score ga_educ ga_h gbv_simple emp, stat(N)

   Stats |     agegp     rural  marita~s   mar_age     child  nvr_en~l    attend  know_c~n      save  withou~t    mobile  asp_ed~y  asp_oc~y  mar_as~e  se_score  lc_score   ga_educ      ga_h  gbv_si~e       emp
---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
       N |     51241     51215     47420      7152     42941     51172     50888     28316     42849     37191     39616     44807     41075     29591     47717     34806     47440     41417     39686     50484
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

.                 
.         *Column 2: Weighted pooled averages
.                 foreach var of varlist agegp rural marital_status mar_age child nvr_enrol attend know_contraception save withoutzeros_save_amount mobile asp_educ_dummy asp_occ_dummy mar_as_age se_score lc_score ga_educ ga_h gbv_simple emp{
  2.                         if `var'==withoutzeros_save_amount{
  3.                                 su `var' if save==1 [w=std_weight]
  4.                         }
  5.                         else {
  6.                         run_chunk `var'
  7.                         su `var' [w=std_weight]
  8.                         }
  9.                 }       

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
       agegp |  51,241  .999999986    .6256497   .4839594          0          1
(26 missing values generated)
(26 missing values generated)
(26 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
       rural |  51,215  .999999985    .6443034   .4787285          0          1
(3,821 missing values generated)
(3,821 missing values generated)
(3,821 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
marital_st~s |  47,420  .999999994    .2029392   .4021919          0          1
(44,089 missing values generated)
(44,089 missing values generated)
(44,089 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
     mar_age |   7,152           1    15.50625   1.887846          8         19
(8,300 missing values generated)
(8,300 missing values generated)
(8,300 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
       child |  42,941  .999999995    .1398903   .3468773          0          1
(69 missing values generated)
(69 missing values generated)
(69 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
   nvr_enrol |  51,172  .999999993    .3082203   .4617626          0          1
(353 missing values generated)
(353 missing values generated)
(353 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
      attend |  50,888  .999999986    .5441798   .4980492          0          1
(22,925 missing values generated)
(22,925 missing values generated)
(22,925 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
know_contr~n |  28,316  .999999993    .6474066   .4777859          0          1
(8,392 missing values generated)
(8,392 missing values generated)
(8,392 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
        save |  42,849  .999999996    .1608764   .3674212          0          1

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
withoutzer~t |   5,620  .141227741    38.38482   62.50018   .0046189   368.6636
(11,625 missing values generated)
(11,625 missing values generated)
(11,625 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
      mobile |  39,616  1.00000001    .6237327   .4844545          0          1
(6,434 missing values generated)
(6,434 missing values generated)
(6,434 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
asp_educ_d~y |  44,807   .99999999    .5918357   .4914993          0          1
(10,166 missing values generated)
(10,166 missing values generated)
(10,166 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
asp_occ_du~y |  41,075  .999999999     .469288    .499062          0          1
(21,650 missing values generated)
(21,650 missing values generated)
(21,650 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
  mar_as_age |  29,591  .999999996    21.78378   4.459158          8         60
(3,524 missing values generated)
(3,524 missing values generated)
(3,524 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
    se_score |  47,717  .999999995    .7081203   .2387716          0          1
(16,435 missing values generated)
(16,435 missing values generated)
(16,435 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
    lc_score |  34,806  1.00000001    .6213137   .1875114          0          1
(3,801 missing values generated)
(3,801 missing values generated)
(3,801 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
     ga_educ |  47,440  1.00000001     .515534   .4997639          0          1
(9,824 missing values generated)
(9,824 missing values generated)
(9,824 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
        ga_h |  41,417  .999999998    .3203761   .2454682          0          1
(11,555 missing values generated)
(11,555 missing values generated)
(11,555 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
  gbv_simple |  39,686           1    .4429303   .4967386          0          1
(757 missing values generated)
(757 missing values generated)
(757 missing values generated)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
         emp |  50,484  .999999991    .2946578   .4558933          0          1

.                 
.         *Component: Demography; Columns AGEP Zambia..SWEDD Benin CCT
.                 tabstat agegp rural marital_status mar_age child, by(source) stat(mean)

Summary statistics: Mean
Group variable: source (IE Name)

         source |     agegp     rural  marita~s   mar_age     child
----------------+--------------------------------------------------
        AGEP_R4 |  .7205357  .3535714    .08125      17.4  .1446429
           AGIK |  .0425656   .408552  .0041024         .  .0009718
          Agile |         1  .3742504  .0051238         .         .
      SWEDD BFA |  .6573475         1  .4940793  16.40357       .25
      SWEDD CIV |  .5906977  .4784496  .2341085  14.92339  .2236719
      SWEDD MLI |  .7698463         1  .3212096  15.59974  .2230916
      SWEDD MRT |         1  .4450242  .2210212  14.94237  .1511758
      SWEDD NER |  .6020173         1  .6837422  15.07104  .2393917
      SWEDD TCD |  .5733083  .3646617  .2518797  14.51965  .1998115
SWEDD_Benin_CCT |  .4985109  .5863666  .0127907  14.84615  .0034913
 SWEDD_Benin_SS |  .5082873  .7207643  .1012717  15.85036    .06639
    TZA_SafeSex |  .5446796         1  .0246914         .  .0361552
----------------+--------------------------------------------------
          Total |  .6278956  .6790003  .1771404  15.40268  .1333458
-------------------------------------------------------------------

.         
.         *Component: Human capital; Columns AGEP Zambia..SWEDD Benin CCT
.                 tabstat nvr_enrol attend know_contraception, by(source) stat(mean)

Summary statistics: Mean
Group variable: source (IE Name)

         source |  nvr_en~l    attend  know_c~n
----------------+------------------------------
        AGEP_R4 |    .00625  .9331652  .7107143
           AGIK |  .0950437  .8798834         .
          Agile |         0         1         .
      SWEDD BFA |  .7687153  .1243068  .5485213
      SWEDD CIV |  .4967401  .3820155  .7694043
      SWEDD MLI |    .55074   .261945  .4570643
      SWEDD MRT |   .118701  .6614408  .8117779
      SWEDD NER |  .6239502  .0048991   .548415
      SWEDD TCD |  .5626767  .3336475  .4849624
SWEDD_Benin_CCT |         0         1   .777667
 SWEDD_Benin_SS |  .4687716         0  .7181329
    TZA_SafeSex |  .0070547  .9488536         .
----------------+------------------------------
          Total |  .2991871  .5483611  .6171776
-----------------------------------------------

.         
.         *Component: Resources; Columns AGEP Zambia..SWEDD Benin CCT
.                 tabstat save mobile, by(source) stat(mean)

Summary statistics: Mean
Group variable: source (IE Name)

         source |      save    mobile
----------------+--------------------
        AGEP_R4 |  .3598214  .2794643
           AGIK |  .1635085  .0177769
          Agile |         .         .
      SWEDD BFA |  .1171442  .7271257
      SWEDD CIV |  .2452713   .976124
      SWEDD MLI |  .2687672   .836176
      SWEDD MRT |  .1496827  .9276929
      SWEDD NER |  .1090514  .6707493
      SWEDD TCD |  .0245052  .7490602
SWEDD_Benin_CCT |  .0802614  .6671079
 SWEDD_Benin_SS |  .1108277  .3860497
    TZA_SafeSex |  .1407995         .
----------------+--------------------
          Total |  .1499452  .6138934
-------------------------------------

.                 tabstat withoutzeros_save_amount if save==1, by(source) stat(mean)

Summary for variables: withoutzeros_save_amount
Group variable: source (IE Name)

         source |      Mean
----------------+----------
        AGEP_R4 |  16.91181
           AGIK |  10.87559
      SWEDD BFA |  54.98216
      SWEDD CIV |  61.01007
      SWEDD MLI |  37.82198
      SWEDD MRT |  44.73496
      SWEDD NER |  11.02217
      SWEDD TCD |  90.04441
SWEDD_Benin_CCT |  23.19875
 SWEDD_Benin_SS |  95.66315
    TZA_SafeSex |  47.14268
----------------+----------
          Total |  38.57839
---------------------------

.                 
.         *Component: Agency; Columns AGEP Zambia..SWEDD Benin CCT
.                 tabstat asp_educ_dummy asp_occ_dummy mar_as_age se_score lc_score ga_educ ga_h gbv_simple, by(source) stat(mean)

Summary statistics: Mean
Group variable: source (IE Name)

         source |  asp_ed~y  asp_oc~y  mar_as~e  se_score  lc_score   ga_educ      ga_h  gbv_si~e
----------------+--------------------------------------------------------------------------------
        AGEP_R4 |         .         .   25.1861  .7159821  .3861607     .9625         .  .6508929
           AGIK |   .983316         .  26.46866  .5062317  .4597578  .1713225         .  .5071303
          Agile |  .9971633  .9220447  22.44051  .8846194         .  .9930462  .7370501  .6238868
      SWEDD BFA |  .2830407  .4628004  19.72568  .8089352  .7214938  .5136322  .3224122  .2772643
      SWEDD CIV |   .238982  .5173492  21.71095  .6674529  .7065698  .4321218  .2982137  .6368992
      SWEDD MLI |         .  .3406617   19.1783  .7326986         .  .4998943  .3110277  .7998897
      SWEDD MRT |  .3027249  .6931691  22.49745   .767417  .7239116  .7166853  .3183464  .1795446
      SWEDD NER |  .1742216  .3627806  16.87047  .6651993  .6979393   .419551  .3274511         .
      SWEDD TCD |  .2982126  .3971698  19.46958   .549448  .6934496  .2931197  .3227144  .4839623
SWEDD_Benin_CCT |  .6492199  .5100034  24.98202  .7313279  .6103102  .4472302  .1179222  .1333222
 SWEDD_Benin_SS |         1   .017613  21.09189  .7600113  .5922307  .2217703  .1282468  .1365109
    TZA_SafeSex |  .9914756         .         .         .         .         .         .         .
----------------+--------------------------------------------------------------------------------
          Total |  .6408151  .5014486  22.46051  .7270347   .630096  .5220911  .3521042  .4278587
-------------------------------------------------------------------------------------------------

.         
.         *Component: Economic Achievement; Columns AGEP Zambia..SWEDD Benin CCT
.                 tabstat emp, by(source) stat(mean)

Summary for variables: emp
Group variable: source (IE Name)

         source |      Mean
----------------+----------
        AGEP_R4 |  .1658354
           AGIK |  .0115425
          Agile |  .3612297
      SWEDD BFA |  .1081331
      SWEDD CIV |  .5593798
      SWEDD MLI |  .2474096
      SWEDD MRT |  .0931793
      SWEDD NER |  .1199131
      SWEDD TCD |  .1301887
SWEDD_Benin_CCT |  .5951357
 SWEDD_Benin_SS |  .9684622
    TZA_SafeSex |   .175485
----------------+----------
          Total |  .3210522
---------------------------

.                 
.         *Final Row (Number of observations); Columns AGEP Zambia..SWEDD Benin CCT
.                 tabstat source_num, by(source) stat(N)

Summary for variables: source_num
Group variable: source (IE Name)

         source |         N
----------------+----------
        AGEP_R4 |      1120
           AGIK |      5145
          Agile |      8197
      SWEDD BFA |      4328
      SWEDD CIV |      3225
      SWEDD MLI |      4749
      SWEDD MRT |      2683
      SWEDD NER |      6940
      SWEDD TCD |      1064
SWEDD_Benin_CCT |      6044
 SWEDD_Benin_SS |      4344
    TZA_SafeSex |      3402
----------------+----------
          Total |     51241
---------------------------

. 
end of do-file

. do "${code}/3_TableS2.3.do"

. //Step 1: Load the pooled data
.         *Enter path below, and remove the * at the start of the line:
.         use "${CleanDataPath}/Harmonized_baseline_final.dta", clear

. 
. //Step 2: Estimate and output the correlations:
.         asdoc pwcorr  /*HCF*/ attend know_contraception /*Resources*/ save withoutzeros_save_amount mobile /*Agency*/ asp_educ_dummy asp_occ_dummy mar_as_age ga_educ ga_h gbv_simple /*EE*/ emp, star(all) replace save(${path}/Output/TableS2.3.doc)

             |   attend know_c~n     save withou~t   mobile asp_ed~y asp_oc~y mar_as~e  ga_educ     ga_h gbv_si~e      emp
-------------+------------------------------------------------------------------------------------------------------------
      attend |   1.0000 
know_contr~n |   0.1404***  1.0000 
        save |   0.0117**  0.1090***  1.0000 
withoutzer~t |  -0.0514***  0.0774***  0.4871***  1.0000 
      mobile |  -0.1225***  0.0348***  0.0542***  0.0347***  1.0000 
asp_educ_d~y |   0.4553***  0.0936*** -0.0001   0.0122** -0.3061***  1.0000 
asp_occ_du~y |   0.4575***  0.1068***  0.0245*** -0.0149***  0.1383***  0.2628***  1.0000 
  mar_as_age |   0.4240***  0.2596***  0.0402*** -0.0249*** -0.1925***  0.2049***  0.1663***  1.0000 
     ga_educ |   0.2347***  0.0780***  0.0226*** -0.0086   0.1077***  0.1287***  0.2942*** -0.0038   1.0000 
        ga_h |   0.2617*** -0.0852***  0.0117**  0.0063   0.0656***  0.1873***  0.3080*** -0.0353***  0.4079***  1.0000 
  gbv_simple |   0.0318***  0.0114*  0.1276***  0.0813***  0.0173***  0.0550***  0.1136*** -0.0719***  0.0825***  0.2340***  1.0000 
         emp |  -0.0626***  0.1064***  0.1062***  0.1166***  0.0174***  0.1313*** -0.1211*** -0.0307*** -0.0378*** -0.1431*** -0.0773***  1.0000 
Click to Open File:  C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Output/TableS2.3.doc

. 
end of do-file

. do "${code}/4_FigureS2.1.do"

. //Step 1: Load the pooled data
.         *Enter path below, and remove the * at the start of the line:
.         use "${CleanDataPath}/Harmonized_baseline_final.dta", clear

.         
. //Step 2: Define program to calculate weights for each (set of) variable(s) used in the regressions:
.         egen source_num = group(source)

.         cap program drop run_chunk

.         program define run_chunk
  1.                 syntax varlist(min=1 max=1)
  2.                         cap drop total_obs weight std_weight
  3.                         egen total_obs = count(source_num) if `varlist' < ., by(source_num)
  4.                         gen weight = 1/total_obs if `varlist' < .
  5.                         sum weight if `varlist' < ., meanonly
  6.                         gen std_weight = weight/r(sum) if `varlist' < .
  7.         end

. 
.         cap drop program run_chunk_two

.         program define run_chunk_two
  1.                 syntax varlist(min=2 max=2)
  2.                 local var1: word 1 of `varlist'
  3.                 local var2: word 2 of `varlist'
  4.                 cap drop total_obs weight std_weight
  5.                 egen total_obs = count(source_num) if `var1' < . & `var2' < ., by(source_num)
  6.                 gen weight = 1/total_obs if `var1' < . & `var2' < .
  7.                 sum weight if `var1' < . & `var2' < ., meanonly
  8.                 gen std_weight = weight/r(sum) if `var1' < . & `var2' < .
  9.         end

. 
.         cap drop program run_chunk_three

.         program define run_chunk_three
  1.                 syntax varlist(min=3 max=3)
  2.                 local var1: word 1 of `varlist'
  3.                 local var2: word 2 of `varlist'
  4.                 local var3: word 3 of `varlist'
  5.                 cap drop total_obs weight std_weight
  6.                 egen total_obs = count(source_num) if `var1' < . & `var2' < . & `var3' < ., by(source_num)
  7.                 gen weight = 1/total_obs if `var1' < . & `var2' < . & `var3' < .
  8.                 sum weight if `var1' < . & `var2' < .  & `var3' < ., meanonly
  9.                 gen std_weight = weight/r(sum) if `var1' < . & `var2' < . & `var3' < .
 10.         end

.         
. 
.  *Step 3: Run relevant regressions. Outcomes:
.         *1. AG: Aspirations for high school education and above (asp_educ_dummy) 
.         *2. AG: Aspirations for high status work (asp_occ_dummy)
.         *3. AG: Gender Attitudes: Household Chores 
.         *4. AG: Attitudes towards GBV (gbv_simple)
.         *5.     EN: Savings dummy
.         *6. EN: Savings amount
.         *7. EN: Mobile in household
.         *8. EA: Employed in the past year
.         
.         *AG outcomes with controls and HC variables:
.         *1. AG: Aspirations for high school education and above (asp_educ_dummy)        
.                         run_chunk_three asp_educ_dummy attend know_contraception
(28,846 missing values generated)
(28,846 missing values generated)
(28,846 missing values generated)

.                         
.                 *with/out both HC vars
.                         qui reg asp_educ_dummy i.marital i.child i.age i.urban i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_no_hc=e(r2_a)

.                         di "Adjusted R-squared without HC components "  adjr_no_hc
Adjusted R-squared without HC components .33248257

.                         
.                         qui reg asp_educ_dummy i.attend i.know_ i.marital i.child i.age i.urban i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_hc=e(r2_a)

.                         di "Adjusted R-squared with HC components " adjr_hc
Adjusted R-squared with HC components .37697305

.                         di "Difference " adjr_hc-adjr_no_hc
Difference .04449047

. 
.         
.         *2. AG: Aspirations for high status work (asp_occ_dummy)        
.                         run_chunk_three asp_occ_dummy  attend know_contraception
(24,366 missing values generated)
(24,366 missing values generated)
(24,366 missing values generated)

.                         
.                 *with/out both HC vars
.                         qui reg asp_occ_dummy i.marital i.child i.age i.urban  i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_no_hc=e(r2_a)

.                         di "Adjusted R-squared without HC components "  adjr_no_hc
Adjusted R-squared without HC components .16250003

.                         
.                         qui reg asp_occ_dummy i.attend i.know_ i.marital i.child i.age i.urban  i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_hc=e(r2_a)

.                         di "Adjusted R-squared with HC components " adjr_hc
Adjusted R-squared with HC components .22619791

.                         di "Difference " adjr_hc-adjr_no_hc
Difference .06369787

.         
.                         
.         *3. AG: Gender Attitudes: Education
.                         run_chunk_three ga_educ  attend know_contraception
(23,387 missing values generated)
(23,387 missing values generated)
(23,387 missing values generated)

.                 
.                 *with/out both HC vars
.                         qui reg ga_educ i.marital i.child i.age i.urban  i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_no_hc=e(r2_a)

.                         di "Adjusted R-squared without HC components "  adjr_no_hc
Adjusted R-squared without HC components .19282094

.                         
.                         qui reg ga_educ i.attend i.know_ i.marital i.child i.age i.urban  i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_hc=e(r2_a)

.                         di "Adjusted R-squared with HC components " adjr_hc
Adjusted R-squared with HC components .20507483

.                         di "Difference " adjr_hc-adjr_no_hc
Difference .0122539

.         
.         *4. AG: Attitudes towards GBV (gbv_simple)
.                         run_chunk_three gbv_simple attend know_contraception
(31,311 missing values generated)
(31,311 missing values generated)
(31,311 missing values generated)

.                         
.                 *with/out both HC vars  
.                         qui reg gbv_simple i.marital i.child i.age i.urban  i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_no_hc=e(r2_a)

.                         di "Adjusted R-squared without HC components "  adjr_no_hc
Adjusted R-squared without HC components .25508878

.                         
.                         qui reg gbv_simple i.attend i.know_ i.marital i.child i.age i.urban  i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_hc=e(r2_a)

.                         di "Adjusted R-squared with HC components " adjr_hc
Adjusted R-squared with HC components .26156138

.                         di "Difference " adjr_hc-adjr_no_hc
Difference .0064726

.                 
.         *5.     EN: Savings dummy
.                         run_chunk_three save attend know_contraception
(23,334 missing values generated)
(23,334 missing values generated)
(23,334 missing values generated)

.                         
.                         *with/out both HC vars  
.                         qui reg save i.marital i.child i.age i.urban i.source_num [w=std_weight] , cluster(source_num)

.                         scalar adjr_no_hc=e(r2_a)

.                         di "Adjusted R-squared without HC components "  adjr_no_hc
Adjusted R-squared without HC components .0740879

. 
.                         qui reg save i.attend i.know_contraception i.marital i.child i.age i.urban i.source_num [w=std_weight] , cluster(source_num)

.                         scalar adjr_hc=e(r2_a)

.                         di "Adjusted R-squared with HC components " adjr_hc
Adjusted R-squared with HC components .08202577

.                         di "Difference " adjr_hc-adjr_no_hc
Difference .00793787

.         
.         
.         *6. EN: Savings amount
.                         run_chunk_three withoutzeros_save_amount attend know_contraception
(24,285 missing values generated)
(24,285 missing values generated)
(24,285 missing values generated)

.                 
.                         *with/out both HC vars  
.                         qui reg withoutzeros_save_amount  i.marital i.child i.age i.urban  i.source_num [w=std_weight] , cluster(source_num)

.                         scalar adjr_no_hc=e(r2_a)

.                         di "Adjusted R-squared without HC components "  adjr_no_hc
Adjusted R-squared without HC components .04124572

.                         
.                         qui reg withoutzeros_save_amount i.attend i.know_contraception i.marital i.child i.age i.urban  i.source_num [w=std_weight] , cluster(source_num)

.                         scalar adjr_hc=e(r2_a)

.                         di "Adjusted R-squared with HC components " adjr_hc
Adjusted R-squared with HC components .04581697

.                         di "Difference " adjr_hc-adjr_no_hc
Difference .00457125

. 
. 
.         *7. EN: Mobile in household
.                         run_chunk_three mobile   attend know_contraception
(23,259 missing values generated)
(23,259 missing values generated)
(23,259 missing values generated)

.                         
.                         *with/out both HC vars          
.                         qui reg mobile  i.marital i.child i.age i.urban  i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_no_hc=e(r2_a)

.                         di "Adjusted R-squared without HC components "  adjr_no_hc
Adjusted R-squared without HC components .25155867

. 
.                         qui reg mobile i.attend i.know_contraception i.marital i.child i.age i.urban  i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_hc=e(r2_a)

.                         di "Adjusted R-squared with HC components " adjr_hc
Adjusted R-squared with HC components .25497036

.                         di "Difference " adjr_hc-adjr_no_hc
Difference .00341169

. 
.         
.         *8. EA: Employed in the past year
.                         run_chunk_three emp attend know_contraception
(23,496 missing values generated)
(23,496 missing values generated)
(23,496 missing values generated)

.                         
.                         *with/out both HC vars          
.                         qui reg emp i.marital i.child i.age i.urban  i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_no_hc=e(r2_a)

.                         di "Adjusted R-squared without HC components "  adjr_no_hc
Adjusted R-squared without HC components .40624617

.                         
.                         qui reg emp i.attend i.know_contraception i.marital i.child i.age i.urban i.source_num[w=std_weight] , cluster(source_num)

.                         scalar adjr_hc=e(r2_a)

.                         di "Adjusted R-squared with HC components " adjr_hc
Adjusted R-squared with HC components .4141641

.                         di "Difference " adjr_hc-adjr_no_hc
Difference .00791793

. 
. 
end of do-file

. do "${code}/5_FigureS2.2.do"

. //Step 1: Load the pooled data
.         *Enter path below, and remove the * at the start of the line:
.         use "${CleanDataPath}/Harmonized_baseline_final.dta", clear

.         
.         
. //Step 2: Define program to calculate weights and variables for each group/profile:
.         gen filt1=(child==0 & marital_status==0) //Reference Group: No child, not married

.         gen filt2=(child==0 & marital_status==1) //Group 2: No child, married

.         gen filt3=(child==1 & marital_status==0 ) //Group 3: With child, not married

.         gen filt4=(child==1 & marital_status==1) //Group 4: With child, married

.         
. // Handle missing values
. foreach var of varlist filt1 filt2 filt3 filt4 {
  2.     replace `var' = . if missing(child) | missing(marital_status)
  3. }       
(12,071 real changes made, 12,071 to missing)
(12,071 real changes made, 12,071 to missing)
(12,071 real changes made, 12,071 to missing)
(12,071 real changes made, 12,071 to missing)

.         
.         
.         gen filter = filt1 + 2*filt2 + 3*filt3 +4*filt4
(12,071 missing values generated)

.         replace filter=. if filter==0
(0 real changes made)

.         *drop filt1 filt2 filt3 filt4
.         tab filter //1 "No children, not married" 2 "No children, married" 3 "With children, not married" 4 "With children, married"

     filter |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     29,857       76.22       76.22
          2 |      3,777        9.64       85.87
          3 |        967        2.47       88.34
          4 |      4,569       11.66      100.00
------------+-----------------------------------
      Total |     39,170      100.00

.         cap egen source_num=group(source)

. 
.         
. capture program drop run_chunk  

. program define run_chunk
  1.                 syntax varlist(min=1 max=1)
  2.                         cap drop total_obs weight std_weight
  3.                         egen total_obs = count(source_num) if `varlist' < ., by(source_num)
  4.                         gen weight = 1/total_obs if `varlist' < .
  5.                         sum weight if `varlist' < ., meanonly
  6.                         gen std_weight = weight/r(sum) if `varlist' < .
  7.         end

.         
.         
.         
. cls

. local row = 1 

. gen var_name = ""
(51,241 missing values generated)

. gen mean_all = .  
(51,241 missing values generated)

. gen mean_ref = . 
(51,241 missing values generated)

. gen coeff_2 =. 
(51,241 missing values generated)

. gen coeff_3 = .  
(51,241 missing values generated)

. gen coeff_4 =  .
(51,241 missing values generated)

. 
. gen p_diff_2_3 = .  // replicate to other differences 
(51,241 missing values generated)

. gen star_2_3 = ""
(51,241 missing values generated)

. //Step 3: Estimate      
. local row = 1 

.         foreach var of varlist attend nvr_enrol save asp_occ_dummy ga_educ gbv_simple emp{
  2.                 run_chunk `var'
  3.                 
.                 replace var_name = "`var'" in `row'
  4.                 su `var' [w=std_weight] 
  5.                 replace mean_all  = `r(mean)' in `row'
  6.                 
.                 su `var' if filter==1 [w=std_weight] 
  7.                         replace mean_ref = `r(mean)' in `row'
  8.                         
.                 
.                 reg `var' filt2 filt3 filt4 i.age i.urban i.source_num [w=std_weight] 
  9.                         
.                         replace coeff_2 = _b[filt2]  in `row'
 10.                         replace coeff_3 = _b[filt3] in `row'
 11.                         replace coeff_4 = _b[filt4] in `row'
 12.                         
.                         
.                  test _b[filt2] = _b[filt3]  // replicate with other differences
 13.                  replace p_diff_2_3  = `r(p)' in `row'
 14.                  
.                  replace star_2_3 = "*" if `r(p)' < 0.1  & `r(p)' >0.05 in `row'
 15.                  replace star_2_3 = "**" if `r(p)' < 0.05  & `r(p)' >0.01 in `row'
 16.                  replace star_2_3 = "***" if `r(p)' < 0.01  & `r(p)' >0.01 in `row'
 17.                  
. 
.                 
.                 
.         local row = `row' + 1 
 18.         }
(353 missing values generated)
(353 missing values generated)
(353 missing values generated)
variable var_name was str1 now str6
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
      attend |  50,888  .999999986    .5441798   .4980492          0          1
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
      attend |  29,681  .675116438    .6471747    .477857          0          1
(1 real change made)
(analytic weights assumed)
(sum of wgt is .8629767715701746)

      Source |       SS           df       MS      Number of obs   =    38,841
-------------+----------------------------------   F(23, 38817)    =   2495.03
       Model |  5773.80711        23  251.035092   Prob > F        =    0.0000
    Residual |   3905.5374    38,817  .100614097   R-squared       =    0.5965
-------------+----------------------------------   Adj R-squared   =    0.5963
       Total |  9679.34451    38,840  .249210724   Root MSE        =     .3172

------------------------------------------------------------------------------
      attend | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       filt2 |  -.2370724   .0064759   -36.61   0.000    -.2497653   -.2243795
       filt3 |  -.1968787   .0101787   -19.34   0.000    -.2168292   -.1769283
       filt4 |  -.2871825   .0063415   -45.29   0.000    -.2996119   -.2747531
             |
         age |
         11  |   .0400105   .0147485     2.71   0.007     .0111031    .0689179
         12  |   .0671567   .0134666     4.99   0.000     .0407619    .0935515
         13  |   .0739523   .0134356     5.50   0.000     .0476181    .1002865
         14  |   .0520326    .013471     3.86   0.000     .0256292    .0784361
         15  |   .0139732   .0134422     1.04   0.299    -.0123738    .0403202
         16  |   .0134331    .013593     0.99   0.323    -.0132095    .0400758
         17  |   .0024323   .0136889     0.18   0.859    -.0243984    .0292629
         18  |  -.0180771   .0137051    -1.32   0.187    -.0449394    .0087853
         19  |  -.0063621   .0140478    -0.45   0.651    -.0338962     .021172
             |
       urban |
   1. Urban  |   .0462657   .0040655    11.38   0.000     .0382972    .0542343
             |
  source_num |
          2  |  -.0845145   .0079875   -10.58   0.000    -.1001703   -.0688588
          4  |  -.6640716   .0086163   -77.07   0.000    -.6809597   -.6471835
          5  |   -.476362    .007508   -63.45   0.000    -.4910778   -.4616462
          6  |  -.5466851   .0079597   -68.68   0.000    -.5622863   -.5310838
          7  |  -.1840515    .007535   -24.43   0.000    -.1988204   -.1692827
          8  |  -.6994062   .0094741   -73.82   0.000    -.7179756   -.6808368
          9  |  -.5329415   .0075266   -70.81   0.000    -.5476937   -.5181893
         10  |   .0666217   .0074549     8.94   0.000     .0520099    .0812336
         11  |  -.8917973   .0076564  -116.48   0.000     -.906804   -.8767906
         12  |   .0477299   .0078433     6.09   0.000     .0323569     .063103
             |
       _cons |    .884568   .0139329    63.49   0.000     .8572591    .9118768
------------------------------------------------------------------------------
(1 real change made)
(1 real change made)
(1 real change made)

 ( 1)  filt2 - filt3 = 0

       F(  1, 38817) =   12.51
            Prob > F =    0.0004
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(69 missing values generated)
(69 missing values generated)
(69 missing values generated)
variable var_name was str6 now str9
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
   nvr_enrol |  51,172  .999999993    .3082203   .4617626          0          1
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
   nvr_enrol |  29,850  .664662097    .2261353   .4183348          0          1
(1 real change made)
(analytic weights assumed)
(sum of wgt is .8633240864055551)

      Source |       SS           df       MS      Number of obs   =    39,163
-------------+----------------------------------   F(23, 39139)    =   1012.40
       Model |  3153.61823        23  137.113836   Prob > F        =    0.0000
    Residual |  5300.76761    39,139  .135434416   R-squared       =    0.3730
-------------+----------------------------------   Adj R-squared   =    0.3726
       Total |  8454.38584    39,162  .215882382   Root MSE        =    .36801

------------------------------------------------------------------------------
   nvr_enrol | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       filt2 |   .2043871   .0074123    27.57   0.000     .1898587    .2189155
       filt3 |   .0524579   .0109104     4.81   0.000     .0310733    .0738425
       filt4 |   .2234446    .007121    31.38   0.000     .2094873    .2374018
             |
         age |
         11  |   .0422415   .0170472     2.48   0.013     .0088284    .0756545
         12  |   .0403473   .0155706     2.59   0.010     .0098286    .0708661
         13  |   .0408084   .0155556     2.62   0.009     .0103191    .0712976
         14  |   .0537246   .0155933     3.45   0.001     .0231614    .0842878
         15  |   .0852005   .0155528     5.48   0.000     .0547167    .1156843
         16  |   .0797047   .0157257     5.07   0.000      .048882    .1105274
         17  |   .0704729   .0158226     4.45   0.000     .0394602    .1014855
         18  |   .0832716   .0158237     5.26   0.000     .0522568    .1142864
         19  |   .0669632   .0162092     4.13   0.000     .0351927    .0987336
             |
       urban |
   1. Urban  |  -.0542129   .0046963   -11.54   0.000    -.0634179    -.045008
             |
  source_num |
          2  |   .1330987   .0093231    14.28   0.000     .1148252    .1513722
          4  |   .6451346   .0098372    65.58   0.000     .6258535    .6644158
          5  |   .4550449   .0086127    52.83   0.000     .4381638     .471926
          6  |   .4584704   .0091135    50.31   0.000     .4406077    .4763332
          7  |    .071234   .0086258     8.26   0.000     .0543273    .0881408
          8  |   .4298631    .010752    39.98   0.000     .4087889    .4509373
          9  |   .5251443   .0086555    60.67   0.000     .5081793    .5421093
         10  |   .0067607   .0086814     0.78   0.436     -.010255    .0237764
         11  |   .4540282   .0088547    51.28   0.000     .4366728    .4713836
         12  |  -.0121423   .0090804    -1.34   0.181      -.02994    .0056555
             |
       _cons |   -.049272   .0161262    -3.06   0.002    -.0808798   -.0176641
------------------------------------------------------------------------------
(1 real change made)
(1 real change made)
(1 real change made)

 ( 1)  filt2 - filt3 = 0

       F(  1, 39139) =  150.05
            Prob > F =    0.0000
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(8,392 missing values generated)
(8,392 missing values generated)
(8,392 missing values generated)
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
        save |  42,849  .999999996    .1608764   .3674212          0          1
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
        save |  29,779  .725910454    .1511829   .3582331          0          1
(1 real change made)
(analytic weights assumed)
(sum of wgt is .942548952879406)

      Source |       SS           df       MS      Number of obs   =    39,085
-------------+----------------------------------   F(23, 39061)    =    146.13
       Model |  424.436448        23  18.4537586   Prob > F        =    0.0000
    Residual |  4932.86119    39,061  .126286096   R-squared       =    0.0792
-------------+----------------------------------   Adj R-squared   =    0.0787
       Total |  5357.29764    39,084  .137071375   Root MSE        =    .35537

------------------------------------------------------------------------------
        save | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       filt2 |   .0250671   .0071691     3.50   0.000     .0110155    .0391187
       filt3 |   .0574028   .0105527     5.44   0.000     .0367191    .0780864
       filt4 |   .0426687   .0068858     6.20   0.000     .0291723     .056165
             |
         age |
         11  |   .0286681   .0164669     1.74   0.082    -.0036074    .0609436
         12  |   .0510761   .0150409     3.40   0.001     .0215955    .0805566
         13  |   .0700344   .0150275     4.66   0.000     .0405802    .0994887
         14  |   .0936688   .0150631     6.22   0.000     .0641449    .1231928
         15  |   .1051302   .0150246     7.00   0.000     .0756816    .1345789
         16  |   .1125542   .0151915     7.41   0.000     .0827784      .14233
         17  |   .1284845   .0152861     8.41   0.000     .0985233    .1584457
         18  |   .1484815   .0152866     9.71   0.000     .1185194    .1784437
         19  |   .1673893   .0156604    10.69   0.000     .1366945    .1980842
             |
       urban |
   1. Urban  |   .0495288   .0045394    10.91   0.000     .0406315     .058426
             |
  source_num |
          2  |  -.1239215   .0090048   -13.76   0.000    -.1415712   -.1062718
          4  |  -.2210321   .0095121   -23.24   0.000    -.2396762   -.2023881
          5  |  -.1006235   .0083307   -12.08   0.000    -.1169519   -.0842951
          6  |  -.0621647   .0088118    -7.05   0.000    -.0794361   -.0448932
          7  |  -.2215755   .0083409   -26.56   0.000    -.2379239   -.2052271
          8  |  -.2459644   .0103967   -23.66   0.000    -.2663422   -.2255866
          9  |  -.3228203   .0083696   -38.57   0.000    -.3392249   -.3064157
         10  |   -.236554   .0083884   -28.20   0.000    -.2529956   -.2201125
         11  |  -.1999431   .0085598   -23.36   0.000    -.2167205   -.1831658
         12  |  -.1623359   .0087798   -18.49   0.000    -.1795445   -.1451272
             |
       _cons |   .2012146   .0155783    12.92   0.000     .1706808    .2317484
------------------------------------------------------------------------------
(1 real change made)
(1 real change made)
(1 real change made)

 ( 1)  filt2 - filt3 = 0

       F(  1, 39061) =    7.27
            Prob > F =    0.0070
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(10,166 missing values generated)
(10,166 missing values generated)
(10,166 missing values generated)
variable var_name was str9 now str13
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
asp_occ_du~y |  41,075  .999999999     .469288    .499062          0          1
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
asp_occ_du~y |  20,231  .577491105    .4424832   .4966931          0          1
(1 real change made)
(analytic weights assumed)
(sum of wgt is .8183180065607303)

      Source |       SS           df       MS      Number of obs   =    29,094
-------------+----------------------------------   F(20, 29073)    =    278.79
       Model |  1136.81828        20  56.8409139   Prob > F        =    0.0000
    Residual |  5927.45645    29,073   .20388183   R-squared       =    0.1609
-------------+----------------------------------   Adj R-squared   =    0.1603
       Total |  7064.27473    29,093  .242816991   Root MSE        =    .45153

------------------------------------------------------------------------------
asp_occ_du~y | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       filt2 |   -.122324   .0091999   -13.30   0.000    -.1403563   -.1042917
       filt3 |  -.0750603   .0156592    -4.79   0.000    -.1057531   -.0443676
       filt4 |  -.1434417   .0091462   -15.68   0.000    -.1613687   -.1255146
             |
         age |
         11  |    -.00758   .0307411    -0.25   0.805     -.067834     .052674
         12  |  -.0012468   .0242796    -0.05   0.959    -.0488358    .0463423
         13  |   .0394431   .0243283     1.62   0.105    -.0082414    .0871276
         14  |   .0083877   .0241628     0.35   0.728    -.0389724    .0557479
         15  |  -.0094841   .0237015    -0.40   0.689      -.05594    .0369718
         16  |   .0000188    .023907     0.00   0.999    -.0468401    .0468776
         17  |  -.0042792   .0240116    -0.18   0.859    -.0513431    .0427846
         18  |  -.0054009   .0240139    -0.22   0.822    -.0524693    .0416674
         19  |  -.0002432   .0245617    -0.01   0.992    -.0483853    .0478989
             |
       urban |
   1. Urban  |   .0078218   .0066555     1.18   0.240    -.0052233    .0208668
             |
  source_num |
          5  |   .0085126    .011541     0.74   0.461    -.0141082    .0311335
          6  |  -.1525392   .0109763   -13.90   0.000    -.1740532   -.1310251
          7  |   .1864856   .0119647    15.59   0.000     .1630342     .209937
          8  |  -.0743774   .0125268    -5.94   0.000    -.0989306   -.0498243
          9  |  -.1116613   .0117852    -9.47   0.000    -.1347608   -.0885617
         10  |  -.0353575   .0117363    -3.01   0.003    -.0583612   -.0123537
         11  |  -.5103075   .0116622   -43.76   0.000     -.533166    -.487449
             |
       _cons |   .5382177   .0243748    22.08   0.000      .490442    .5859935
------------------------------------------------------------------------------
(1 real change made)
(1 real change made)
(1 real change made)

 ( 1)  filt2 - filt3 = 0

       F(  1, 29073) =    7.69
            Prob > F =    0.0056
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(3,801 missing values generated)
(3,801 missing values generated)
(3,801 missing values generated)
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
     ga_educ |  47,440  1.00000001     .515534   .4997639          0          1
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
     ga_educ |  26,358  .639564354    .4767442   .4994684          0          1
(1 real change made)
(analytic weights assumed)
(sum of wgt is .85216451505039)

      Source |       SS           df       MS      Number of obs   =    35,496
-------------+----------------------------------   F(22, 35473)    =    439.69
       Model |  1894.37867        22  86.1081212   Prob > F        =    0.0000
    Residual |  6946.96055    35,473  .195837977   R-squared       =    0.2143
-------------+----------------------------------   Adj R-squared   =    0.2138
       Total |  8841.33921    35,495  .249086891   Root MSE        =    .44254

------------------------------------------------------------------------------
     ga_educ | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       filt2 |  -.0788579   .0090047    -8.76   0.000    -.0965075   -.0612084
       filt3 |   -.048708   .0136087    -3.58   0.000    -.0753815   -.0220346
       filt4 |  -.0915951    .008713   -10.51   0.000    -.1086728   -.0745174
             |
         age |
         11  |   .0140086   .0216673     0.65   0.518    -.0284601    .0564772
         12  |  -.0038311   .0193015    -0.20   0.843    -.0416627    .0340006
         13  |   -.000522   .0192954    -0.03   0.978    -.0383415    .0372975
         14  |  -.0108495    .019325    -0.56   0.575    -.0487272    .0270282
         15  |  -.0121693   .0192732    -0.63   0.528    -.0499453    .0256067
         16  |  -.0060174   .0195333    -0.31   0.758    -.0443033    .0322685
         17  |  -.0049049   .0196689    -0.25   0.803    -.0434565    .0336468
         18  |   .0029234   .0196644     0.15   0.882    -.0356193    .0414662
         19  |   .0048608   .0201826     0.24   0.810    -.0346977    .0444193
             |
       urban |
   1. Urban  |   .0129261   .0056407     2.29   0.022     .0018702     .023982
             |
  source_num |
          2  |   -.804132   .0114243   -70.39   0.000     -.826524   -.7817401
          4  |  -.4058995   .0118333   -34.30   0.000    -.4290931   -.3827058
          5  |  -.5148737    .010363   -49.68   0.000    -.5351855    -.494562
          6  |  -.4354696    .010956   -39.75   0.000    -.4569437   -.4139956
          7  |  -.2359651   .0103832   -22.73   0.000    -.2563164   -.2156138
          8  |   -.474233   .0129327   -36.67   0.000    -.4995815   -.4488845
          9  |  -.6550694   .0104192   -62.87   0.000    -.6754913   -.6346475
         10  |  -.5211089    .010441   -49.91   0.000    -.5415737   -.5006442
         11  |  -.7385901   .0106535   -69.33   0.000    -.7594712    -.717709
             |
       _cons |   .9685116   .0198583    48.77   0.000     .9295888    1.007434
------------------------------------------------------------------------------
(1 real change made)
(1 real change made)
(1 real change made)

 ( 1)  filt2 - filt3 = 0

       F(  1, 35473) =    3.88
            Prob > F =    0.0490
(1 real change made)
(0 real changes made)
variable star_2_3 was str1 now str2
(1 real change made)
(0 real changes made)
(11,555 missing values generated)
(11,555 missing values generated)
(11,555 missing values generated)
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
  gbv_simple |  39,686           1    .4429303   .4967386          0          1
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
  gbv_simple |  24,277  .675389294    .3984403   .4895871          0          1
(1 real change made)
(analytic weights assumed)
(sum of wgt is .8769941881946579)

      Source |       SS           df       MS      Number of obs   =    30,494
-------------+----------------------------------   F(21, 30472)    =    441.71
       Model |  1740.89298        21  82.8996655   Prob > F        =    0.0000
    Residual |  5719.00538    30,472   .18768067   R-squared       =    0.2334
-------------+----------------------------------   Adj R-squared   =    0.2328
       Total |  7459.89836    30,493  .244642979   Root MSE        =    .43322

------------------------------------------------------------------------------
  gbv_simple | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       filt2 |   .0253307   .0098046     2.58   0.010     .0061133    .0445481
       filt3 |   .0419914   .0140262     2.99   0.003     .0144995    .0694833
       filt4 |   .0733065   .0092977     7.88   0.000     .0550827    .0915303
             |
         age |
         11  |  -.0069974    .022039    -0.32   0.751    -.0501949       .0362
         12  |  -.0024459   .0197434    -0.12   0.901    -.0411438    .0362521
         13  |   .0144824   .0197157     0.73   0.463    -.0241612     .053126
         14  |   .0249495   .0197578     1.26   0.207    -.0137765    .0636756
         15  |   .0470362    .019685     2.39   0.017     .0084528    .0856195
         16  |   .0449401   .0199643     2.25   0.024     .0058092     .084071
         17  |   .0306946   .0201259     1.53   0.127     -.008753    .0701422
         18  |   .0314778   .0201375     1.56   0.118    -.0079926    .0709482
         19  |   .0148037   .0206894     0.72   0.474    -.0257485    .0553559
             |
       urban |
   1. Urban  |  -.0370537   .0057637    -6.43   0.000    -.0483509   -.0257566
             |
  source_num |
          2  |  -.1155216   .0117529    -9.83   0.000    -.1385578   -.0924854
          4  |  -.4105148   .0121221   -33.87   0.000    -.4342746    -.386755
          5  |  -.0228314   .0106036    -2.15   0.031    -.0436149   -.0020479
          6  |   .1032697   .0113721     9.08   0.000       .08098    .1255594
          7  |  -.4837371   .0106311   -45.50   0.000    -.5045745   -.4628997
          9  |    -.17057   .0106657   -15.99   0.000    -.1914753   -.1496648
         10  |   -.515443   .0106863   -48.23   0.000    -.5363886   -.4944974
         11  |  -.5181768   .0109098   -47.50   0.000    -.5395606   -.4967931
             |
       _cons |   .6372662   .0202318    31.50   0.000     .5976111    .6769214
------------------------------------------------------------------------------
(1 real change made)
(1 real change made)
(1 real change made)

 ( 1)  filt2 - filt3 = 0

       F(  1, 30472) =    1.07
            Prob > F =    0.3002
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(757 missing values generated)
(757 missing values generated)
(757 missing values generated)
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
         emp |  50,484  .999999991    .2946578   .4558933          0          1
(1 real change made)

    Variable |     Obs      Weight        Mean   Std. dev.       Min        Max
-------------+-----------------------------------------------------------------
         emp |  29,259  .667410058    .3056646   .4606962          0          1
(1 real change made)
(analytic weights assumed)
(sum of wgt is .8636215382593946)

      Source |       SS           df       MS      Number of obs   =    38,496
-------------+----------------------------------   F(23, 38472)    =   1126.10
       Model |  3236.31543        23  140.709367   Prob > F        =    0.0000
    Residual |  4807.20594    38,472  .124953367   R-squared       =    0.4024
-------------+----------------------------------   Adj R-squared   =    0.4020
       Total |  8043.52137    38,495  .208949769   Root MSE        =    .35349

------------------------------------------------------------------------------
         emp | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       filt2 |  -.0005878   .0072039    -0.08   0.935    -.0147077    .0135321
       filt3 |   .0804001    .010645     7.55   0.000     .0595356    .1012646
       filt4 |   .0274841    .006956     3.95   0.000     .0138502    .0411181
             |
         age |
         11  |  -.0236902   .0163969    -1.44   0.149    -.0558286    .0084482
         12  |  -.0054827    .014985    -0.37   0.714    -.0348537    .0238884
         13  |  -.0097842   .0149643    -0.65   0.513    -.0391147    .0195463
         14  |   .0088846   .0150099     0.59   0.554    -.0205351    .0383043
         15  |   .0348062   .0149735     2.32   0.020     .0054578    .0641546
         16  |   .0399023   .0151443     2.63   0.008     .0102191    .0695855
         17  |    .038952   .0152346     2.56   0.011     .0090918    .0688121
         18  |   .0540112    .015242     3.54   0.000     .0241365    .0838859
         19  |   .0649943   .0156083     4.16   0.000     .0344016     .095587
             |
       urban |
   1. Urban  |  -.1057605   .0045719   -23.13   0.000    -.1147215   -.0967994
             |
  source_num |
          2  |   -.120569   .0090315   -13.35   0.000    -.1382711    -.102867
          4  |   -.133628   .0096457   -13.85   0.000    -.1525339   -.1147221
          5  |   .3793455   .0083853    45.24   0.000     .3629102    .3957809
          6  |   .0056173   .0089437     0.63   0.530    -.0119125    .0231471
          7  |   -.100007   .0083914   -11.92   0.000    -.1164545   -.0835596
          8  |  -.1594483    .010544   -15.12   0.000    -.1801148   -.1387819
          9  |  -.0347394   .0084083    -4.13   0.000    -.0512198    -.018259
         10  |   .4215781   .0084385    49.96   0.000     .4050384    .4381179
         11  |   .7748467   .0086284    89.80   0.000     .7579348    .7917587
         12  |  -.0484514   .0088797    -5.46   0.000    -.0658559    -.031047
             |
       _cons |   .1996979   .0155683    12.83   0.000     .1691836    .2302122
------------------------------------------------------------------------------
(1 real change made)
(1 real change made)
(1 real change made)

 ( 1)  filt2 - filt3 = 0

       F(  1, 38472) =   44.86
            Prob > F =    0.0000
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)

.         
.         foreach var in  coeff_2 coeff_3 coeff_4 {
  2.                 
.                 *scaling part
.                 replace `var' = `var' / mean_ref
  3.         }
(7 real changes made)
(7 real changes made)
(7 real changes made)

.         
.         * generate coeff as string and add stars to them 
.         
.         
.         browse var_name mean_all mean_ref coeff_*  p_diff* star_2_3

.         
.         
. cls

. local varlist attend nvr_enrol save asp_occ_dummy ga_educ gbv_simple emp

. 
. // Initialize or reset variables
. capture confirm variable var_name

. if _rc {
.     gen var_name = ""
. }

. else {
.     replace var_name = ""
(7 real changes made)
. }

. 
. foreach var in mean_all mean_ref {
  2.     capture confirm variable `var'
  3.     if _rc {
  4.         gen `var' = .
  5.     }
  6.     else {
  7.         replace `var' = .
  8.     }
  9. }
(7 real changes made, 7 to missing)
(7 real changes made, 7 to missing)

. 
. foreach var in coeff_2 coeff_3 coeff_4 {
  2.     capture confirm variable `var'
  3.     if _rc {
  4.         gen `var' = .
  5.     }
  6.     else {
  7.         replace `var' = .
  8.     }
  9. }
(7 real changes made, 7 to missing)
(7 real changes made, 7 to missing)
(7 real changes made, 7 to missing)

. 
. foreach i in 2 3 4 {
  2.     capture confirm variable p_diff_1_`i'
  3.     if _rc {
  4.         gen p_diff_1_`i' = .
  5.     }
  6.     else {
  7.         replace p_diff_1_`i' = .
  8.     }
  9.     
.     capture confirm variable star_1_`i'
 10.     if _rc {
 11.         gen star_1_`i' = ""
 12.     }
 13.     else {
 14.         replace star_1_`i' = ""
 15.     }
 16. }
(51,241 missing values generated)
(51,241 missing values generated)
(51,241 missing values generated)
(51,241 missing values generated)
(51,241 missing values generated)
(51,241 missing values generated)

. 
. 
. // Estimate
. local row = 0

. foreach var of local varlist {
  2.     local ++row
  3.     run_chunk `var'
  4.     
.     replace var_name = "`var'" in `row'
  5.     
.     qui su `var' [w=std_weight] 
  6.     replace mean_all = r(mean) in `row'
  7.     
.     qui su `var' if filter == 1 [w=std_weight] 
  8.     replace mean_ref = r(mean) in `row'
  9.     
.     qui reg `var' filt2 filt3 filt4 i.age i.urban i.source_num [w=std_weight] 
 10.     
.     foreach i in 2 3 4 {
 11.         replace coeff_`i' = _b[filt`i'] in `row'
 12.         
.         // Test against reference group (coefficient different from 0)
.         qui test filt`i' = 0
 13.         replace p_diff_1_`i' = r(p) in `row'
 14.         replace star_1_`i' = cond(r(p)<0.01, "***", ///
>                              cond(r(p)<0.05, "**", ///
>                              cond(r(p)<0.1, "*", ""))) in `row'
 15.     }
 16. }
(353 missing values generated)
(353 missing values generated)
(353 missing values generated)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
variable star_1_2 was str1 now str3
(1 real change made)
(1 real change made)
(1 real change made)
variable star_1_3 was str1 now str3
(1 real change made)
(1 real change made)
(1 real change made)
variable star_1_4 was str1 now str3
(1 real change made)
(69 missing values generated)
(69 missing values generated)
(69 missing values generated)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(8,392 missing values generated)
(8,392 missing values generated)
(8,392 missing values generated)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(10,166 missing values generated)
(10,166 missing values generated)
(10,166 missing values generated)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(3,801 missing values generated)
(3,801 missing values generated)
(3,801 missing values generated)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(11,555 missing values generated)
(11,555 missing values generated)
(11,555 missing values generated)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(757 missing values generated)
(757 missing values generated)
(757 missing values generated)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(0 real changes made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)

. 
. // Scaling coefficients
. foreach var in coeff_2 coeff_3 coeff_4 {
  2.     replace `var' = `var' / mean_ref if mean_ref != 0 & mean_ref != .
  3. }
(7 real changes made)
(7 real changes made)
(7 real changes made)

. 
. // Format numeric variables
. foreach var of varlist mean_all mean_ref coeff_* p_diff_1_* {
  2.     format `var' %9.3f
  3. }

. 
. // Generate coefficients as string with stars
. forvalues i = 2/4 {
  2.     capture confirm variable coeff_`i'_star
  3.     if _rc {
  4.         gen coeff_`i'_star = string(coeff_`i', "%9.3f") + star_1_`i'
  5.     }
  6.     else {
  7.         replace coeff_`i'_star = string(coeff_`i', "%9.3f") + star_1_`i'
  8.     }
  9. }

. 
. // Display results
. browse var_name mean_all mean_ref coeff_* coeff_*_star p_diff_1_* star_1_*

. 
end of do-file

. 
. log close
      name:  <unnamed>
       log:  C:/WBG/Rep-checks/RR_AFR_2024_224/Spotlight 2/Output/log.txt
  log type:  text
 closed on:  13 Nov 2024, 09:57:06
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
